Been messing around with code academy intro to Ruby, to prepare myself for coding bootcamp and this thing bugs me:
Code:
print "Say something with an S!"
user_input = gets.chomp.downcase!
if user_input.include? "s"
user_input.gsub!(/s/, "th")
else
puts "There is no 's'"
end
When I type with no "s" it promts an error: "undefined method `include?' for nil:NilClass"
Where is the bug? Or is it a bug withing app academy?
This is how it's supposed to look at the end of the chapter:
Code:
print "Thtring, pleathe!: "
user_input = gets.chomp
user_input.downcase!
if user_input.include? "s"
user_input.gsub!(/s/, "th")
else
puts "Nothing to do here!"
end
puts "Your string is: #{user_input}"
Where is the difference? Oh, and how can I put "" inside the string?