Can anybody explain why some of operator symbols cann't be written directly as symbols in irb, whereas when passed to ruby interpreter it runs without any issue ? It looks like irb parses an expression as unfinished and prompts with an asterisk as awaiting continue of input:
irb> test_symbol = :+
irb* ^C
irb> test_symbol = :-
irb* ^C
irb> test_symbol = :*
=> :*
irb> test_symbol = :<
=> :<
Other symbols that fail at parsing are :%, :&, :^, :/, :|, :~ . I can pass those symbols as strings, ie. test_symbol = :'+' however this is just a workaround to a possible bug. Or a feature ?
Can somebody shed some light to this behaviour ?
I installed
1.9.3devon my machine and can confirm thatirbdoes appear to be "awaiting input" after using a symbol like that.However, this doesn't actually affect how the eval loop functions. As an example, I tried this:
So while it seems that IRB is waiting for you to finish an expression, it does seemt to parse the expression correctly. I can't find any bug reports around this issue.