J
jney
Hello,
Is there a cleaner way to check if no field have been set than the
following code ?
=> true
Is there a cleaner way to check if no field have been set than the
following code ?
=> true
Is there a cleaner way to check if no field have been set than the
following code ?
=> true
Is there a cleaner way to check if no field have been set than the
following code ?
=> true
I'd consider this a tad cleaner - although it is not really rock solid:
irb(main):015:0> x.methods - x.class.instance_methods
=> [:foo, :foo=]
irb(main):016:0> x = OpenStruct.new
=> #<OpenStruct>
irb(main):017:0> x.foo = 1
=> 1
irb(main):018:0> x.methods - x.class.instance_methods
=> [:foo, :foo=]
Kind regards
robert
=> [:foo, :foo=]x = OpenStruct.new=> # said:x.foo=1 => 1
x.methods - x.class.instance_methods => [:foo, :foo=]
x.delete_field :foo => 1
x.methods - x.class.instance_methods
=> [:foo, :foo=]x.foo=1 => 1
x.methods - x.class.instance_methods => [:foo, :foo=]
x.delete_field :foo => 1
x.methods - x.class.instance_methods
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.