From: Catsquotl Date: 2012-02-21T15:14:49+09:00 Subject: Enumerable question Hi, I have a class which an each method to itterate over its instance variables. I am trying to do a string search on all those variables. However it seems to just evaluate the last yielded instance var. the following test. ----- a = Acupunt.new(["bl","vloed","tingping","pols","luo","klaart hitte","verdrijft wind"]) a.each {|check| puts check} ----- prints out all vars. a.search("bl") however prints "not found ["klaart hitte", "verdrijft wind"] is not bl" a.search("hitte") prints found I don't understand why search my search only works if the last yielded var matches en not the previous ones Anyone want to point me in the right direction? Eelco ------------------------------------------- class Acupunt include Enumerable attr_reader :afk, :name,:chname, :locatie, :aard, :actie def initialize(arr) set_instance_variables arr @actie.split!(",") end def set_instance_variables arr @afk=arr[0] @name=arr[1] @chname=arr[2] @locatie=arr[3] @aard=arr[4] @actie=arr[5..-1] end def each yield "#{@afk}" yield "#{@name}" yield "#{@chname}" yield "#{@locatie}" yield "#{@aard}" yield "#{@actie}" end def search str self.each do |check| if check.eql? str "found" else "not found #{check} is not #{str}" end end end end