Hi guys,
I have a string variable named as ‘last_name’. how can i check
NULL(nil) of this veriable?
as exapmle
if ( empty(last_name) ) #*
# code
else
#code
end
How can I write the syntax in the if statement(*)?
Please help me.
Sasaki
Hi guys,
I have a string variable named as ‘last_name’. how can i check
NULL(nil) of this veriable?
as exapmle
if ( empty(last_name) ) #*
# code
else
#code
end
How can I write the syntax in the if statement(*)?
Please help me.
Sasaki
On 3/27/07, Sasaki [email protected] wrote:
Hi,
I think the .nil? method is the one you’re looking for:
irb(main):001:0> some_nil = nil
=> nil
irb(main):002:0> some_nil.nil?
=> true
Hope that helps,
-Harold
On Mar 27, 4:30 am, Sasaki [email protected] wrote:
How can I write the syntax in the if statement(*)?
Please help me.Sasaki
–
Posted viahttp://www.ruby-forum.com/.
Note that an empty string is not nil.
So if you need to check for nil or empty try:
if last_name.nil? || last_name.empty? #…
Cheers
Chris
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs