Skip to content

Commit 3e32b11

Browse files
committed
Add final step to put together everything
It seemed like a good idea to me to add a step at the end to pull together everything learned above into one semi-practical example.
1 parent 7c8c39f commit 3e32b11

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,24 @@ pluralize("kiwi")
134134

135135
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."
136136
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
137155
end
138156

139157
next_step "getting_started"

0 commit comments

Comments
 (0)