On Tue, Jun 28, 2011 at 4:17 PM, serialhex <serialhex / gmail.com> wrote:

> this code works:
> pry(main)> print <<NUMS
>
> but this:
> pry(main)> str = ''
> pry(main)> str <<NUMS
>


gives me:
> SyntaxError: (pry):43: Invalid octal digit
>
>

In the first case, puts is a method. In the second, str is a variable. You
can pass arguments to methods, which is what you do. You cannot pass
arguments to variables. The `<<` in `<<NUMS` is not an operator, it is part
of the here document syntax (I take it to mean "put the string here, where
I'm pointing to") so it expands to `str "..."` which is more obviously
incorrect.

If you're trying to append to the string, then it should be `str << <<NUMS`
if you're trying to assign it to the string, then it should be `str =
<<NUMS`