Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to Check If a Variable is Defined in Ruby

Ruby has this defined? keyword that helps you check if a Variable is defined or not. If the variable exists you’ll get its type: apple = 1 defined?(apple) # "local-variable" If it doesn’t you’ll get nil: defined?(bacon) # nil This is like Javascript’s typeof operator. If you want to know the class of an object […]

The post How to Check If a Variable is Defined in Ruby appeared first on RubyGuides. Don't miss your free gift here :)



This post first appeared on Black Bytes, please read the originial post: here

Share the post

How to Check If a Variable is Defined in Ruby

×

Subscribe to Black Bytes

Get updates delivered right to your inbox!

Thank you for your subscription

×