diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-11-03 11:04:35 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-11-03 11:04:35 +0000 |
commit | aae36756dcc4d5debcaabd03379796bc41360bc4 (patch) | |
tree | ff4ed4df6473229d846ff4f658094fcf66c4c744 /lib/ostruct.rb | |
parent | c960141333a9bc384bafbcfaa49672e48677d6dd (diff) |
* object.c (Init_Object): added Object#object_id, new name for
Object#id. [new]
* object.c (rb_obj_id_obsolete): give warning for Object#id.
* numeric.c (fix_intern): added Fixnum#to_sym. [new]
* object.c (sym_to_sym): rename from Symbol#intern
* enum.c (enum_zip): added Enumerable#zip. [new]
* array.c (rb_ary_zip): added Array#zip.
* error.c (init_syserr): remove sys_nerr dependency.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/ostruct.rb')
-rw-r--r-- | lib/ostruct.rb | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/ostruct.rb b/lib/ostruct.rb index 9106f6e068..a5c51022d4 100644 --- a/lib/ostruct.rb +++ b/lib/ostruct.rb @@ -13,7 +13,7 @@ class OpenStruct @table = {} if hash for k,v in hash - @table[k] = v + @table[k] = v.to_sym end end end @@ -26,19 +26,16 @@ class OpenStruct raise ArgumentError, "wrong # of arguments (#{len} for 1)", caller(1) end mname.chop! - @table[mname] = args[0] + @table[mname.intern] = args[0] elsif args.length == 0 - @table[mname] + @table[mid] else raise NameError, "undefined method `#{mname}'", caller(1) end end - + def delete_field(name) - if name.class == Fixnum - name = name.id2name - end - @table.delete name + @table.delete name.to_sym end def inspect |