by Argorak · 12y ago · 0 comments
The syntactical equality between a variable and a method call on self has the advantage to make things like this possible. E.g. if i have:
foo = DataBase.lazy_load(:foo)
do_something_with(foo)
can easily be refactored to def foo
DataBase.lazy_load(:foo)
end
do_something_with(foo)
I think that to be a strong-point of the Ruby language, speaking about values and not about the technicalities. Also, every external access to a value has to happen through a Method.Also, you are complaining about the Rails API more than anything else. E.g. in DataMapper, it was quite obvious that those attributes do hard work (e.g. coercion), because you had to explicitly define them in the first place.
f :: () -> T is a function that still takes a (meaningless) value
g = map f list is just a value.