In Ruby, like many languages, a method's arguments are not automatically assigned as instance variables.
This works:
def initialize(a)
@a = a
end
This doesn't:
def initialize(@a)
end
In CoffeeScript, for example, this works:
constructor: (@name) ->
There are a lot of other syntactic sugar in Ruby, such as the ||= operator, the unary & on symbols, etc. Is there any reason, technical or otherwise, why this sugar isn't part of the design?
Edit
The scope of the question is not limited to initialize.
In CoffeeScript you can also do
class Foo
baz: (@bar) ->