Skip to content

Commit b2cf87e

Browse files
committed
Merge branch 'mh-ruby-language-final-step' of https://github.com/mxhold/docs into mxhold-mh-ruby-language-final-step
2 parents f067a67 + 3e32b11 commit b2cf87e

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

sites/en/intro-to-rails/ruby_language.step

+29-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ steps do
1515

1616
message "Yours might look different, but it should look something like this:"
1717

18-
console_without_message "1.9.3p362 :001 > "
18+
console_without_message "irb(main):001:0>"
1919
end
2020

2121
step do
@@ -109,6 +109,16 @@ end
109109
message "This prints `YAY!` if the value stored in `my_variable` is greater than 1."
110110

111111
message "Try changing the `>` in the conditional to a `<`."
112+
113+
message "If you want to do something else when the statement evaluates to false, you can use an `else`:"
114+
115+
console_without_message <<-RUBY
116+
if my_variable > 1
117+
puts "YAY!"
118+
else
119+
puts "BOO!"
120+
end
121+
RUBY
112122
end
113123

114124
step do
@@ -124,6 +134,24 @@ pluralize("kiwi")
124134

125135
message "Methods can also return data. In this case, pluralize returns the word with an 's' added to the end of it. In Ruby, methods return whatever the last line of the method evaluates to."
126136
end
137+
138+
step do
139+
message "Putting it all together, let's make a method that says your opinion of some fruits:"
140+
console_without_message <<-RUBY
141+
def my_opinion(fruits)
142+
fruits.each do |fruit|
143+
if fruit == "pizza"
144+
puts "pizza is the best!!!"
145+
else
146+
puts pluralize(fruit) + " are pretty good, I guess..."
147+
end
148+
end
149+
end
150+
my_opinion(["apple", "pizza", "orange"])
151+
RUBY
152+
153+
message "Try changing this method to say what your favorite fruit is."
154+
end
127155
end
128156

129157
next_step "getting_started"

0 commit comments

Comments
 (0)