_ [Iterator][ãã¶ã¤ã³ãã¿ã¼ã³]Head First ãã¶ã¤ã³ãã¿ã¼ã³ãåçµãã - 9ç« Iterator ãã¿ã¼ã³ é¢åãªã®ã§ Enumerable ã使ããææã #!/usr/bin/ruby -Ks class Menu include Enumerable def initialize( item ) @item = item end def each @item.each do |menu| yield menu end end end def main menuItems = [ "K&Bã®ãã³ã±ã¼ãæé£", "é常ã®ãã³ã±ã¼ãæé£", "ã¯ããã«"] menu = Menu.new( menuItems ) menu.each {|n| puts n } end main % ./menu.rb K&Bã®ãã³ã±ã¼ãæé£ é常ã®ãã³ã±ã¼ãæé£ ã¯ããã« _ [m
{{#tags}}- {{label}}
{{/tags}}