This document provides an introduction to the Ruby programming language. It covers basic Ruby syntax like variables, conditionals, loops, arrays, hashes, and classes. It also discusses how to install and use Ruby on Rails, including generating scaffolds to quickly build out models, views, and controllers. Key topics covered include routes, controllers, models, views, databases, and the MVC framework pattern in Rails. Resources for learning more about Ruby and Rails are provided at the end.
36. Mam, please take
each item for me to
bill
cart = [“biscuit”, milk”, “shampoo”, “tampons” ]
cart.each do |item|
puts item
end
37. Exercise 2
- Create an array of marks you got in your
last assessment.
- Find if the sum of odd numbers is greater
than the sum of even numbers, if it is, you
have big odds at passing.
- Pass this information or bad luck will follow
42. Alternate way to write hash
slang = {
lol: “laugh out loud”,
brb: “Be right back”
}
slang[:lol]
=> laught out loud
43. Exercise 3
- Create a list of ipl team hashes
- with batsmen (3) name as key and their
sixes as values.
a) Find the sixes hit by a batsmen of a given
name
46. Exercise 4
a) Create a method rajini_style. Return his
dialogue (your favorite).
b) Create a factorial method that gets a
number and returns the factorial