On 23.10.2010 19:16, jney wrote: > Is there a cleaner way to check if no field have been set than the > following code ? > >>>> o = OpenStruct.new > => #<OpenStruct> >>>> o.inspect == "#<OpenStruct>" > => true >>>> o.one_field = true > => true >>>> o.inspect == "#<OpenStruct>" > => false >>>> o.delete_field 'one_field' > => nil >>>> o.inspect == "#<OpenStruct>" > => 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 -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/