value binding and function binding

V

Vivek Nallur

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
 

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

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,135
Messages
2,570,783
Members
47,341
Latest member
hanifree

Latest Threads

Top