Ruby Language
Goals
Steps
Step 1
irbirb(main):001:0>Step 2
Next try some simple math that's built into Ruby. Type these lines into IRB:3 + 3 7 * 6Step 3
my_variable = 5Step 4
my_variable + 2 my_variable * 3Step 5
fruits = ["kiwi", "strawberry", "plum"]Step 6
Type this in the terminal:fruits = fruits + ["orange"] fruits = fruits - ["kiwi"]Step 7
7.class "kiwi".class fruits.classStep 8
fruits.length fruits.firstfruits.methodsfruits.methods.sortStep 9
fruits.each do |fruit| puts fruit endStep 10
if my_variable > 1 puts "YAY!" endif my_variable > 1 puts "YAY!" else puts "BOO!" endStep 11
def pluralize(word) word + "s" end pluralize("kiwi")Step 12
def my_opinion(fruits) fruits.each do |fruit| if fruit == "pizza" puts "pizza is the best!!!" else puts pluralize(fruit) + " are pretty good, I guess..." end end end my_opinion(["apple", "pizza", "orange"])
Next Step:
Go on to Getting Started