Why is this an invalid string?

S

Siep Korteling

str = "#$"

-:1: unterminated string meets end of file

Is there is something special about this sequence? '#$' is fine.
 
B

Ben Bleything

str =3D =A0"#$"

-: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 =3D "local"
@foo =3D "ivar"
$foo =3D "global"
"local: #foo, ivar: #@foo, global: #$foo"
=3D> "local: #foo, ivar: ivar, global: global"

So, yes, there is something special about "#$" :)

Ben
 
G

Gary Wright

=20
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 Wright=
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,142
Messages
2,570,818
Members
47,362
Latest member
eitamoro

Latest Threads

Top