Glossary Flashcards
# Array.new constructor variable = \_\_\_\_(some_array)
Array.new
# Array.new constructor variable = \_\_\_\_(some_array)
Array.new
\_\_\_\_ do |arg| # Do something to each element, referenced as arg end
array.each
array.each ___ |arg|
# Do something to each element, referenced as arg
end
do
array.each do \_\_\_\_ # Do something to each element, referenced as arg end
|arg|
array.each do |arg| # Do something to each element, referenced as arg \_\_\_\_
end
[[1,2,3], [4,5,6], 7, [[8,9], 10]].____
=> [1,2,3,4,5,6,7,8,9,10]
flatten
[1,1,1,2,3,4,3,3].___
=> [1,2,3,4]
uniq
# Blocks that span only one line usually use the braces form objs.\_\_\_ { |obj| do_something }
method
# Blocks that span only one line usually use the braces form objs.method {\_\_\_ do_something }
|obj|
# Blocks that span only one line usually use the braces form objs.method \_\_ |obj| do_something \_\_
{ }
objs.method \_\_\_ |obj| # do first line # do second line # ... # do nth line end
do
objs.method do \_\_\_ # do first line # do second line # ... # do nth line end
|obj|
objs.method do |obj| # do first line # do second line # ... # do nth line \_\_\_
end
x __y // returns true if two things are equal
==
x__y // returns true if two things are not equal
!=
x __ y // returns true if x is less than or equal to y
x __ y // returns true if x is greater than or equal to y
> =
__
comment line
comment line
=end
=begin
=begin
comment line
comment line
__
=end
empty_hash = Hash.new
=> {}
my_hash = Hash.new(“The Default”)
my_hash[“random_key”]
=>__
“The Default”
empty_hash = Hash.new
=> {}
my_hash = Hash.new(“The Default”)
my_hash[“random_key”]
=>__
“The Default”
\_\_\_\_ do |arg| # Do something to each element, referenced as arg end
array.each
array.each ___ |arg|
# Do something to each element, referenced as arg
end
do
array.each do \_\_\_\_ # Do something to each element, referenced as arg end
|arg|
array.each do |arg| # Do something to each element, referenced as arg \_\_\_\_
end
[[1,2,3], [4,5,6], 7, [[8,9], 10]].____
=> [1,2,3,4,5,6,7,8,9,10]
flatten
[1,1,1,2,3,4,3,3].___
=> [1,2,3,4]
uniq
# Blocks that span only one line usually use the braces form objs.\_\_\_ { |obj| do_something }
method
# Blocks that span only one line usually use the braces form objs.method {\_\_\_ do_something }
|obj|
# Blocks that span only one line usually use the braces form objs.method \_\_ |obj| do_something \_\_
{ }