How can I join two strings (both are numbers) together without having them added together? For example:
@output = 2567 + 18
What I Don’t Want:
The result returns "2585" (it has added the two numbers together mathematically).
What I Do Want:
The result returns "256718". As you can see, this time the two numbers have been joined together, not added.
A Real Example:
Profile.create(:permalink => 2585 && User.last.id)
When I run that line from my model – the row titled "permalink" simply gets the last created user ID, and "2585" isn’t joined in front of it. Also, if I used the "+" method instead of "&&" like in the first example, the two numbers are added together mathematically.
Any ideas?
Convert both values to strings. The first with a string literal and the second with an explicit conversion using the
to_smethod.