summaryrefslogtreecommitdiff
path: root/struct.c
diff options
context:
space:
mode:
authork0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-12 15:12:05 +0000
committerk0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-12 15:12:05 +0000
commit2406207cbba15384868255d75dd3b8cb71b60e85 (patch)
tree6a1e9499eca08ac50b195a0673acdfe1378bace0 /struct.c
parent8411f58ed70c1e6dc4e35589c94fd231c4e384d2 (diff)
struct.c: don't explain implementation details
of keyword_init option. [DOC] [ci skip] It's implemented to take Hash, but it's just implementation detail and it's intended to behave in the same way as keyword arguments (for :keyword_init option too). Also I unified coding style of r61137 with other places. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61182 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'struct.c')
-rw-r--r--struct.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/struct.c b/struct.c
index e025228828..3a21ec8dbf 100644
--- a/struct.c
+++ b/struct.c
@@ -475,7 +475,8 @@ rb_struct_define_under(VALUE outer, const char *name, ...)
* Customer.new("Dave", "123 Main")
* #=> #<struct Customer name="Dave", address="123 Main">
*
- * If keyword_init: true option is given, .new takes Hash instead of Array.
+ * If keyword_init: true option is given, .new takes keyword arguments instead
+ * of normal arguments.
*
* Customer = Struct.new(:name, :address, keyword_init: true)
* #=> Customer
@@ -536,7 +537,8 @@ rb_struct_s_def(int argc, VALUE *argv, VALUE klass)
rb_get_kwargs(argv[argc-1], keyword_ids, 0, 1, kwargs);
--argc;
keyword_init = kwargs[0];
- } else {
+ }
+ else {
keyword_init = Qfalse;
}
@@ -599,7 +601,8 @@ struct_hash_set_i(VALUE key, VALUE val, VALUE arg)
args->unknown_keywords = rb_ary_new();
}
rb_ary_push(args->unknown_keywords, key);
- } else {
+ }
+ else {
rb_struct_modify(args->self);
RSTRUCT_SET(args->self, i, val);
}
@@ -627,7 +630,8 @@ rb_struct_initialize_m(int argc, const VALUE *argv, VALUE self)
rb_raise(rb_eArgError, "unknown keywords: %s",
RSTRING_PTR(rb_ary_join(arg.unknown_keywords, rb_str_new2(", "))));
}
- } else {
+ }
+ else {
if (n < argc) {
rb_raise(rb_eArgError, "struct size differs");
}