Symbol to string issue

String interpolation is an implicit to_s call. So, something like this:

result = "hello #{expr}"

is more or less equivalent to this:

result = "hello " + expr.to_s

As karim79 said, a symbol is not a string but symbols do have to_s methods so your interpolation works; your attempt at using + for concatenation doesn’t work because there is no implementation of + available that understand a string on the left side and a symbol on the right.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)