-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirstFile.rb
More file actions
54 lines (46 loc) · 1.09 KB
/
firstFile.rb
File metadata and controls
54 lines (46 loc) · 1.09 KB
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
message_type = 'EXPIRE_TRUCK_AVAILABILITY'
puts "hello all"
# Add the strings before and after around each parm and print
def surround(before, after, *items)
items.each { |x| print before, x, after, "\n" }
end
surround('[', ']', 'this', 'that', 'the other')
print "\n"
surround('<', '>', 'Snakes', 'Turtles', 'Snails', 'Salamanders', 'Slugs',
'Newts')
print "\n"
def boffo(a, b, c, d)
print "a = #{a} b = #{b}, c = #{c}, d = #{d}\n"
end
# Use * to adapt between arrays and arguments
a1 = ['snack', 'fast', 'junk', 'pizza']
a2 = [4, 9]
boffo(*a1)
boffo(17, 3, *a2)
a = 10
b = a +
10
c = [ 5, 4,
10 ]
d = [ a ] \
+ c
print "#{a} #{b} [", c.join(" "), "] [", d.join(" "), "]\n";
# Simple for loop using a range.
for i in (1..4)
print i," "
end
print "\n"
for i in (1...4)
print i," "
end
print "\n"
# Running through a list (which is what they do).
items = [ 'Mark', 12, 'goobers', 18.45 ]
for it in items
print it, " "
end
print "\n"
# Go through the legal subscript values of an array.
for i in (0...items.length)
print items[0..i].join(" "), "\n"
end