value binding and function binding

Discussion in 'Ruby' started by Vivek Nallur, Sep 25, 2003.

  1. Vivek Nallur

    Vivek Nallur Guest

    Hi

    I was just wandering through some lisp code and I saw this:
    (let ((x 1))
    (flet ((x (y) (+ x y)))
    (x x)))

    (I'm not sure if the indentation came out properly)

    A transliteration(?) of this code gave me an error!

    [nvivek@indus nvivek]$ cat t.rb
    x = 1;
    def x (y)
    x += y
    end
    x x

    [nvivek@indus nvivek]$ ruby t.rb
    t.rb:3:in `x': undefined method `+' for nil:NilClass (NoMethodError)
    from t.rb:5

    All I want to do is to check if ruby supports the same identifier having
    both a value binding as well as a function binding.

    Comments?

    -vivek


    --

    Smith & Wesson: The original point-and-click interface
     
    Vivek Nallur, Sep 25, 2003
    #1
    1. Advertising

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. Jordan
    Replies:
    2
    Views:
    2,571
    Jordan
    Feb 10, 2004
  2. Amit
    Replies:
    6
    Views:
    13,915
    Assimalyst
    Oct 24, 2006
  3. Replies:
    2
    Views:
    907
    Kevin Grover
    Oct 20, 2006
  4. CSINVA
    Replies:
    6
    Views:
    422
    Paul Delcogliano
    Nov 7, 2007
  5. JcFx
    Replies:
    0
    Views:
    315
Loading...

Share This Page