Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Just a few suggestions/hints! #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 17 additions & 1 deletion bridge-of-death.rb
@@ -1,12 +1,21 @@
# Ruby style generally suggests limiting lines to 80 characters. This can be
# a pain in the *** for long strings, and there are a number of ways to deal
# with that. Heredocs, appending multiple strings...
puts "He who would cross the Bridge of Death must answer me these questions three, ere the other side he see!"

# check out print vs. puts, as it doesn't add a newline to the end
puts "What..is your name?"
name = gets.chomp
puts "What...is your quest?"
quest = gets.chomp

# Try a case/when instead of an if/elsif structure. This is basically
# a readability change, it is a bit more concise. Unlike many other
# languages, it will work with Regexps, since it uses === instead of ==
if name =~ /\barthur\b/i;
puts "What is the airspeed velocity of a coconut laden swallow?"
swallow = gets.chomp
# Try redoing the newlines/spacing on this if/else/end block
if swallow.downcase == "african or european"
puts "I don't know that! AAAAAAAAAAAAaaaaaaaaaahhhhhhh!!!"
else puts "You have been cast into the Gorge of Eternal Peril!"
Expand All @@ -27,8 +36,15 @@
end
else puts "Your father smelt of elderberries and your mother was a hamster! I fart in your general direction!"
end
$end
$end # what is this?


# embedding multiple lines with ; is frowned upon in Ruby, although it does work
# For short if statements, use:
# action if condition
# instead of
# if condition
# action
# end
if quest.downcase != "the search for the holy grail"; puts "You are uncultured swine!"
end