From: "Peña, Botp" Date: 2007-02-02T10:28:34+09:00 Subject: Re: Ruby << is ambiguos From: Wolfgang Nádasi-Donner [mailto:wonado@donnerweb.de] : # There is a similar problem with "?" and "?:". # irb(main):001:0> ?2 # => 50 k # irb(main):002:0> sep = "x" * (true?2:1) # SyntaxError: compile error # (irb):2: parse error, unexpected ':', expecting ')' # sep = "x" * (true?2:1) # ^ # from (irb):2 careful. "?" is a valid char for identifiers and is also used for inline if. stupid example, irb(main):002:0> def true? irb(main):003:1> true irb(main):004:1> end => nil irb(main):005:0> true? => true irb(main):006:0> true? 2 ArgumentError: wrong number of arguments (1 for 0) from (irb):6:in `true?' from (irb):6 irb(main):007:0> true?2 ArgumentError: wrong number of arguments (1 for 0) from (irb):7:in `true?' from (irb):7 irb(main):008:0> true?2:1 SyntaxError: compile error (irb):8: parse error, unexpected ':', expecting $ true?2:1 ^ from (irb):8 irb(main):009:0> true?2 ArgumentError: wrong number of arguments (1 for 0) from (irb):9:in `true?' from (irb):9 irb(main):011:0> true? 2:1 SyntaxError: compile error (irb):11: parse error, unexpected ':', expecting $ true? 2:1 ^ from (irb):11 irb(main):012:0> true? ? 2:1 => 2 irb(main):013:0> true ? 2:1 => 2 # irb(main):003:0> sep = "x" * (true ?2:1) # => "xx" k. kind regards -botp