Perhaps using elsif instead of elseif will help.  But your code makes
no attempt to return a value, so the nil is expected.
If you are planning on returning a value, do something like this:
result = if person == "Somebody"
  "foo"
elsif person == "Another"
  "else if returned"
else
  "no match"
end

On Apr 23, 12:07 pm, DrV <thevalent...@gmail.com> wrote:
> I've been working on a new project and created a custom method for one
> of the models.  Nothing major.
>
> I brought up the console in --sandbox mode (also have tried in
> standard console), and tried playing with it.  To my surprise there
> was a problem with the if/elseif conditional.  The elseif portion
> simply would not work.  So I tried a couple commands as so to test the
> actual if/elseif integrity like so:
>
> person = "Jim"
> if person == "Sally"
> puts "Hi Sally"
> elseif person == "Jim"
> puts "Hi Jim"
> end
>
> This returns nil.  If I put a final <else> catch it will return that
> value.  What am I doing wrong?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to