string-concatenation
Format specifier for integer variables in format() for EXECUTE?
This would be shorter, faster and safer: CREATE OR REPLACE FUNCTION get_parent_ltree(parent_id bigint, tbl_name regclass , OUT parent_ltree ltree) LANGUAGE plpgsql AS $func$ BEGIN EXECUTE format(‘SELECT l_tree FROM %s WHERE id = $1′, tbl_name) INTO parent_ltree USING parent_id; END $func$; Why? Most importantly, use the USING clause of EXECUTE for parameter values. Don’t convert them … Read more
What is the difference between VBScript’s + and & operator?
The & operator does string concatenation, that is, forces operands to be converted to strings (like calling CStr on them first). +, in its turn, forces addition if one of the expressions is numeric. For example: 1 & 2 gives you 12, whereas 1 + 2 “1” + 2 1 + “2” give you 3. … Read more
Efficiently repeat a character/string n times in Scala
For strings you can just write “abc” * 3, which works via StringOps and uses a StringBuffer behind the scenes. For characters I think your solution is pretty reasonable, although char.toString * n is arguably clearer. Do you have any reason to suspect the List.fill version isn’t efficient enough for your needs? You could write … Read more
Is python += string concatenation bad practice?
Is it bad practice? It’s reasonable to assume that it isn’t bad practice for this example because: The author doesn’t give any reason. Maybe it’s just disliked by him/her. Python documentation doesn’t mention it’s bad practice (from what I’ve seen). foo += ‘ooo’ is just as readable (according to me) and is approximately 100 times … Read more
Concatenating strings doesn’t work as expected [closed]
Your code, as written, works. You’re probably trying to achieve something unrelated, but similar: std::string c = “hello” + “world”; This doesn’t work because for C++ this seems like you’re trying to add two char pointers. Instead, you need to convert at least one of the char* literals to a std::string. Either you can do … Read more
const char* concatenation
In your example one and two are char pointers, pointing to char constants. You cannot change the char constants pointed to by these pointers. So anything like: strcat(one,two); // append string two to string one. will not work. Instead you should have a separate variable(char array) to hold the result. Something like this: char result[100]; … Read more
String equals and == with String concatenation [duplicate]
When you do System.out.println(“Object and literal compare by double equal to :: ” + s1 == s2); you are first concatenating the string “Object and literal compare by double equal to :: ” with the string s1, which will give “Object and literal compare by double equal to :: jai” then, you are checking if … Read more
Python Pandas concatenate a Series of strings into one string
You can join a string on the series directly: In [3]: ‘ ‘.join(df[‘text’]) Out[3]: ‘Hello world !’