1 Mar 2012 15:28
Re: Rubymoticons
Bartosz Dziewoński <matma.rex <at> gmail.com>
2012-03-01 14:28:52 GMT
2012-03-01 14:28:52 GMT
2012/3/1 Eric Christopherson <echristopherson <at> gmail.com>:
> irb should also treat symbols that way -- and not halfway interpret
> them as operators. (I say "halfway" because on the one hand it waits
> for the next line, as it would with a dangling operator; but on the
> other hand, it then just throws away the symbol and evaluates the next
> line as if it stood alone.)
No. It does not discard it; it's simply the effect of syntax. Consider this:
ruby -e 'p eval(":-; 1")'
There are two expressions evaled here, ":-" and "1".
Now this:
ruby -e 'p eval(":-\n1")'
Just as above, there are two expressions. IRB *does not strip
newlines*; and when evaling some code, only the result of last
expresion is returned.
The only bug here (or, IMO, a lack of feature) is that IRB does not
parse the code at all; it simply checks if the line ends with an
operator, a dot or a backslash, and in this case does not eval code
immediately, but joins it with next line of input.
-- Matma Rex
RSS Feed