Ruby on Rails Thursday, August 29, 2013

Hi Ruby on Rails community!

I am trying to write a program that uses the .match command to find out
if a string contains a certain word-then using that information write a
conditional statement. The issue I am running into is that I am self
teaching myself and do not really know how to properly use this new
found str. method. Right now this is what my code looks like

def your_plans(activity) #want to use a method for this one
if /activity/.match("movie")
#this is where I get it wrong, I am not sure if this is the proper way
to present the match, and if i am #putting the argument in the correct
position.
puts "I love movies too!"
else
puts "why didn't you see a movie?"
end
end

puts your_plans("Yesterday, I went to go see a movie")


it is super basic, as I am just a starter. I think the rest of my code
is correct, i just cant figure out the match method. If anyone has some
pointers on why certain pieces go where that would be really helpful. I
have been using this site to look up and learn methods.
http://www.ruby-doc.org/core-1.9.3/String.html

thanks!

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/25db479ad61ce73b66b95dd1efd3a9b7%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment