File tree Expand file tree Collapse file tree 1 file changed +18
-18
lines changed
Expand file tree Collapse file tree 1 file changed +18
-18
lines changed Original file line number Diff line number Diff line change 1- def input ( string = "Enter string" )
2- puts string
3- enteredText = gets . chomp
4- return enteredText
1+ # START of BASE functions
2+ def input ( string = 'Enter string' )
3+ puts string
4+ gets . chomp
55end
66
7- def print ( string = "" )
7+ def print ( string = '' )
88 puts ( string )
99end
1010
11- def initArray ( dimensions = [ 10 ] , default_element = nil )
12- size = dimensions . first
13- if dimensions . length > 1
14- dimensions . shift
15- return Array . new ( size , initArray ( dimensions ) )
16- else
17- return Array . new ( size , default_element )
18- end
19- end
20- print ( "Hello World" )
11+ def init_array ( dimensions = [ 10 ] , default_element = nil )
12+ size = dimensions . first
13+ if dimensions . length > 1
14+ dimensions . shift
15+ Array . new ( size , init_array ( dimensions , default_element ) )
16+ else
17+ Array . new ( size , default_element )
18+ end
19+ end
20+
21+ # END of BASE functionsprint("Hello World")
2122
2223x = 3
2324name = "Bob"
@@ -37,17 +38,16 @@ def triple(number)
3738y = triple ( 7 )
3839print ( y )
3940
40- names = initArray ( [ 5 ] )
41+ names = init_array ( [ 5 ] )
4142names [ 0 ] = "Ahmad"
4243names [ 1 ] = "Ben"
4344names [ 2 ] = "Catherine"
4445names [ 3 ] = "Dan"
4546names [ 4 ] = "Elijah"
4647print ( names [ 3 ] )
4748
48- board = initArray ( [ 8 , 8 ] )
49+ board = init_array ( [ 8 , 8 ] )
4950board [ 0 ] [ 0 ] = "rook"
50- print ( board [ 0 , 0 ] )
5151
5252entry = input ( "Please enter your name" )
5353
You can’t perform that action at this time.
0 commit comments