-
Notifications
You must be signed in to change notification settings - Fork 0
/
comprehension.rb
72 lines (50 loc) · 877 Bytes
/
comprehension.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
def hello
print "Hello World!"
end
def print_name(name)
print "My name is #{name}"
end
def add_2(x, y)
return x + y
end
city_list = ["Austin", "San Francisco", "Chicago", "New York"]
def city_love(cities)
cities.each { |city| print "I love #{city}."}
end
numbers = [[4,2,1],[7,9,6],[3,5,9]]
def value_viewer(array)
array.each do |x|
x.each do |y|
print y
end
end
end
location = {
"city" => "Austin",
"state" => "Texas"
}
def associated(hash)
hash.each { |key, value| return "#{key} is associated with #{value}"}
end
class Hair
def initialize(color)
@color = red
end
end
class Hair
def initialize(color, length)
@color = color
@length = length
end
end
class Person
def initialize(name)
@name = name
end
def name
@name
end
end
def say_names(names)
names.each{ |name| puts "#{name}" }
end