# Noob question for wxMenu.get\_menu\_items()

**URL:** <https://www.ruby-forum.com/t/noob-question-for-wxmenu-get-menu-items/126431>\
**Category:** wxRuby\
**Created:** [January 18, 2008, 7:35am UTC](https://www.ruby-forum.com/t/noob-question-for-wxmenu-get-menu-items/126431 "2008-01-18T07:35:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![EchoB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/45deac/32.png) [@EchoB](https://www.ruby-forum.com/u/EchoB)\
**Post date:** [January 18, 2008, 7:35am UTC](https://www.ruby-forum.com/t/noob-question-for-wxmenu-get-menu-items/126431/1 "2008-01-18T07:35:16Z")

</div>

How do I iterate through the pseudo-template list class containing  
wxMenuItem pointers.  
Am still a bit of a Ruby/wxRuby noob.  
Currently have this:

pp mymenu.get\_menu\_items()

which prints:  
#SWIG::TYPE\_p\_wxMenuItemList:0x4634fa8

However when I try to do:  
mymenu.get\_menu\_items().each {|key| …} it tells me there is no each  
method for this class (SWIG::TYPE\_p\_wxMenuItemList)

---

<div class="post-metadata">

**Author:** ![EchoB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/45deac/32.png) [@EchoB](https://www.ruby-forum.com/u/EchoB)\
**Post date:** [January 18, 2008, 4:23pm UTC](https://www.ruby-forum.com/t/noob-question-for-wxmenu-get-menu-items/126431/2 "2008-01-18T16:23:46Z")

</div>

EchoB wrote:

> How do I iterate through the pseudo-template list class containing  
> wxMenuItem pointers.  
> Am still a bit of a Ruby/wxRuby noob.  
> Currently have this:
> 
> pp mymenu.get\_menu\_items()
> 
> which prints:  
> #SWIG::TYPE\_p\_wxMenuItemList:0x4634fa8  
> Ooops, it’s a bug. Thanks for the report. In the meantime you should be  
> able to do something like the following to iterate over each item inside  
> a Menu

```
class MyMenu < Wx::Menu
  def each
    (0...menu_item_count).each do | i |
      yield find_item_by_position(i)
    end
  end
end

```

cheers  
alex
