Syntax error with array interpolation

Discussion in 'Ruby' started by Ronald Fischer, Jun 25, 2007.

  1. Below is a code snippet which gives me some headache:

    def headache
    yield(*(foo(1)),"bar")
    end

    def foo(n)
    [n,n+2,n+5]
    end

    headache { |a,b,c,d| puts a.to_s; puts b.to_s; puts c.to_s; puts d }

    I had expected that this would print


    --=20
    Ronald Fischer <>
    Phone: +49-89-452133-162
    =20
     
    Ronald Fischer, Jun 25, 2007
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Balaji
    Replies:
    3
    Views:
    10,481
  2. damian birchler

    array of function pointers --- syntax error!?

    damian birchler, Oct 20, 2004, in forum: C Programming
    Replies:
    5
    Views:
    533
    Dave Vandervies
    Oct 20, 2004
  3. David Tran
    Replies:
    6
    Views:
    1,215
    Eric Hodel
    Mar 17, 2005
  4. gabriele renzi
    Replies:
    2
    Views:
    374
    gabriele renzi
    Dec 31, 2005
  5. Ronald Fischer

    Syntax error with array interpolation

    Ronald Fischer, Jun 25, 2007, in forum: Ruby
    Replies:
    2
    Views:
    282
    Daniel Lucraft
    Jun 25, 2007
  6. Good Night Moon
    Replies:
    9
    Views:
    544
    Rick DeNatale
    Jul 25, 2007
  7. Mark Richards
    Replies:
    3
    Views:
    508
    Tad McClellan
    Nov 18, 2007
  8. Isaac Won
    Replies:
    15
    Views:
    341
    Oscar Benjamin
    Jan 24, 2013
Loading...