parentheses and newlines

Discussion in 'Ruby' started by jsnark, Feb 17, 2012.

  1. jsnark

    jsnark Guest

    Can anyone explain the following behavior? I would expect both
    expressions to fail, but the first unexpectedly succeeds.

    $ irb --version
    irb 0.9.6(09/06/30)
    $ ruby --version
    ruby 1.9.2p136 (2010-12-25) [x86_64-linux]
    $ irb
    irb(main):001:0> (2
    irb(main):002:1> 3)
    => 3
    irb(main):003:0> (2 3)
    SyntaxError: (irb):3: syntax error, unexpected tINTEGER, expecting ')'
    (2 3)
    ^
    from /usr/local/ruby-1.9.2/bin/irb:12:in `<main>'
     
    jsnark, Feb 17, 2012
    #1
    1. Advertisements

  2. irb(main):001:0> (2;3)
    => 3

    Line terminator is more than just whitespace.

    Kind regards

    robert
     
    Robert Klemme, Feb 17, 2012
    #2
    1. Advertisements

  3. Same behaviour in ruby with eval. So no irb problem.

    mfg, simon .... l
     
    Simon Krahnke, Feb 18, 2012
    #3
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.