Use instance_of? for robustness. : instance_of « Reflection « Ruby
- Ruby
- Reflection
- instance_of
Use instance_of? for robustness.
# 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
Related examples in the same category