str = “#$”
-:1: unterminated string meets end of file
Is there is something special about this sequence? ‘#$’ is fine.
str = “#$”
-:1: unterminated string meets end of file
Is there is something special about this sequence? ‘#$’ is fine.
On Mon, Jan 10, 2011 at 1:06 PM, Siep K. [email protected]
wrote:
str = “#$”
-:1: unterminated string meets end of file
Is there is something special about this sequence? ‘#$’ is fine.
When you’re referring to a variable with a sigil ($global, @instance),
you can omit the {} in string interpolation. Thus:
foo = “local”
@foo = “ivar”
$foo = “global”
“local: #foo, ivar: #@foo, global: #$foo”
=> “local: #foo, ivar: ivar, global: global”
So, yes, there is something special about “#$”
Ben
On Jan 10, 2011, at 4:10 PM, Ben B. wrote:
On Mon, Jan 10, 2011 at 1:06 PM, Siep K. [email protected] wrote:
str = “#$”
So, yes, there is something special about “#$”
Just to be a bit more explicit…
There is a global variable named $"
So in Siep’s example, the parser is using the second quote as the name
of the global variable and not as the closing quote for the string
literal.
Gary W.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs