mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Make Struct#keyword_init? return nil by default [Feature #18008]
This commit is contained in:
parent
33bea3bdff
commit
3e7a7fb28a
2 changed files with 8 additions and 10 deletions
15
struct.c
15
struct.c
|
@ -356,19 +356,14 @@ rb_struct_s_inspect(VALUE klass)
|
|||
*
|
||||
* Examples:
|
||||
* Foo = Struct.new(:a)
|
||||
* Foo.keyword_init? # => false
|
||||
* Foo.keyword_init? # => nil
|
||||
* Bar = Struct.new(:a, keyword_init: true)
|
||||
* Bar.keyword_init? # => true
|
||||
* Baz = Struct.new(:a, keyword_init: false)
|
||||
* Baz.keyword_init? # => false
|
||||
*/
|
||||
static VALUE
|
||||
rb_struct_s_keyword_init_p(VALUE klass)
|
||||
{
|
||||
if (RTEST(rb_struct_s_keyword_init(klass))) {
|
||||
return Qtrue;
|
||||
} else {
|
||||
return Qfalse;
|
||||
}
|
||||
}
|
||||
|
||||
#define rb_struct_s_keyword_init_p rb_struct_s_keyword_init
|
||||
|
||||
static VALUE
|
||||
setup_struct(VALUE nstr, VALUE members)
|
||||
|
|
|
@ -144,6 +144,9 @@ module TestStruct
|
|||
|
||||
struct = @Struct.new(:a, :b, keyword_init: false)
|
||||
assert_equal(false, struct.keyword_init?)
|
||||
|
||||
struct = @Struct.new(:a, :b)
|
||||
assert_nil(struct.keyword_init?)
|
||||
end
|
||||
|
||||
def test_initialize
|
||||
|
|
Loading…
Add table
Reference in a new issue