Skip to content
Tags

,

local variable v/s instance variable

July 12, 2012

While a local variable needs to exist before we call a method on it, an instance variable with its name itself is assigned the nil class…

so you can do things like this:

> @result.present?
=> false
1.9.3p194 :054 > result.present?
NameError: undefined local variable or method `result' for main:Object
Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: