[ruby-core:112585] [Ruby master Feature#19466] Class.new takes a block, why doesn't Module.new take a block?

Issue #19466 has been reported by ioquatix (Samuel Williams). ---------------------------------------- Feature #19466: Class.new takes a block, why doesn't Module.new take a block? https://bugs.ruby-lang.org/issues/19466 * Author: ioquatix (Samuel Williams) * Status: Open * Priority: Normal ---------------------------------------- ```ruby Class.new do #... equivalent to class_eval end ``` So, why don't we introduce: ```ruby Module.new do #... equivalent to class_eval end ``` -- https://bugs.ruby-lang.org/

Issue #19466 has been updated by sawa (Tsuyoshi Sawada). You can. ```ruby A = Module.new do def foo; "foo" end end class B; include A end B.new.foo # => "foo" ``` ---------------------------------------- Feature #19466: Class.new takes a block, why doesn't Module.new take a block? https://bugs.ruby-lang.org/issues/19466#change-102035 * Author: ioquatix (Samuel Williams) * Status: Open * Priority: Normal ---------------------------------------- ```ruby Class.new do #... equivalent to class_eval end ``` So, why don't we introduce: ```ruby Module.new do #... equivalent to class_eval end ``` -- https://bugs.ruby-lang.org/

Issue #19466 has been updated by ioquatix (Samuel Williams). Ahh, so why does `EnvUtil` not use this? Maybe it's legacy? ---------------------------------------- Feature #19466: Class.new takes a block, why doesn't Module.new take a block? https://bugs.ruby-lang.org/issues/19466#change-102037 * Author: ioquatix (Samuel Williams) * Status: Open * Priority: Normal ---------------------------------------- ```ruby Class.new do #... equivalent to class_eval end ``` So, why don't we introduce: ```ruby Module.new do #... equivalent to class_eval end ``` -- https://bugs.ruby-lang.org/

Issue #19466 has been updated by ioquatix (Samuel Williams). Status changed from Open to Closed Okay, I confirmed it's working by my own hand, haha. I updated the PR to take advantage of that. https://github.com/ruby/ruby/pull/7376/files#diff-84e45206777a1891b7ce021458... ---------------------------------------- Feature #19466: Class.new takes a block, why doesn't Module.new take a block? https://bugs.ruby-lang.org/issues/19466#change-102038 * Author: ioquatix (Samuel Williams) * Status: Closed * Priority: Normal ---------------------------------------- ```ruby Class.new do #... equivalent to class_eval end ``` So, why don't we introduce: ```ruby Module.new do #... equivalent to class_eval end ``` -- https://bugs.ruby-lang.org/
participants (2)
-
ioquatix (Samuel Williams)
-
sawa (Tsuyoshi Sawada)