# don't do the block (do |t|...end) unless the variable myString is a string. myString = "asdf" if myString.instance_of?( String ) myString.split.each do |t| puts t end end