# Openstruct oddity

**URL:** <https://www.ruby-forum.com/t/openstruct-oddity/78687>\
**Category:** Ruby\
**Created:** [December 7, 2006, 9:20pm UTC](https://www.ruby-forum.com/t/openstruct-oddity/78687 "2006-12-07T21:20:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 7, 2006, 9:20pm UTC](https://www.ruby-forum.com/t/openstruct-oddity/78687/1 "2006-12-07T21:20:52Z")

</div>

In reference to thread [117889](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/117889)&nbsp;Wed, 27 Oct 2004,

[http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/117889](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/117889)

&nbsp;

does anyone know what's happened to this? This is about openstruct picking up a defined method when the same name is passed to openstruct send method. I ran into this problem with ruby 1.8.5 and I found in the above thread that it was a known anomaly. It seems that Matz intended to fix it. Still pending or I should use openstruct differently?

&nbsp;

In addition to that, although might be related, I don't know, it seems that openstruct also picks up&nbsp;method from module.

&nbsp;

This one works as expected:

&nbsp;

def foo

&nbsp; "foo"

end

OpenStruct.new.foo

=\> nil

&nbsp;

&nbsp;

This one does not:

&nbsp;

module Foo

def foo

&nbsp; "foo"

end

end 

include Foo

OpenStruct.new.foo

=\> foo

&nbsp;

This is surely an anomaly too, is it not?

&nbsp;

-andre

&nbsp;

PS: I could have continued from that thread but I'm not sure what the community preference here in regarding old, old thread.

&nbsp;

  

* * *
 [Visit MSN Holiday Challenge for your chance to win up to $50,000 in Holiday cash from MSN today!](http://g.msn.com/8HMAENUS/2728??PS=47575)
