From: rr.rosas@... Date: 2016-07-19T13:43:05+00:00 Subject: [ruby-core:76448] [Ruby trunk Feature#8563] Instance variable arguments Issue #8563 has been updated by Rodrigo Rosenfeld Rosas. Even if define_attr_initialize would accept a block to enhance the initializer besides initializing instance variables it doesn't support default arguments. I'd certainly prefer the original proposal which I find more useful. It's not obvious what array.each(&:to_i) does either but people get used to it because it's handy. I think it's the same about this proposal although it's quite familiar for people using this feature in other languages like CoffeeScript and Crystal among others. ---------------------------------------- Feature #8563: Instance variable arguments https://bugs.ruby-lang.org/issues/8563#change-59693 * Author: Tsuyoshi Sawada * Status: Assigned * Priority: Normal * Assignee: Yukihiro Matsumoto ---------------------------------------- Often times, people want to assign given arguments to instance variables, especially inside the method `initialize`: ~~~Ruby def initialize foo, bar, buz @foo, @bar, @buz = foo, bar, buz ... end ~~~ I propose to let method definition take instance variables as arguments so that: ~~~Ruby def initialize @foo, @bar, @buz ... end ~~~ would be equivalent as above. -- https://bugs.ruby-lang.org/ Unsubscribe: