Glossary Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q
# Array.new constructor
variable = \_\_\_\_(some_array)
A

Array.new

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
# Array.new constructor
variable = \_\_\_\_(some_array)
A

Array.new

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
\_\_\_\_ do |arg|
  # Do something to each element, referenced as arg
end
A

array.each

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

array.each ___ |arg|
# Do something to each element, referenced as arg
end

A

do

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
array.each do \_\_\_\_
  # Do something to each element, referenced as arg
end
A

|arg|

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
array.each do |arg|
  # Do something to each element, referenced as arg
\_\_\_\_
A

end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

[[1,2,3], [4,5,6], 7, [[8,9], 10]].____

=> [1,2,3,4,5,6,7,8,9,10]

A

flatten

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

[1,1,1,2,3,4,3,3].___

=> [1,2,3,4]

A

uniq

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
# Blocks that span only one line usually use the braces form
objs.\_\_\_ { |obj| do_something }
A

method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
# Blocks that span only one line usually use the braces form
objs.method {\_\_\_ do_something }
A

|obj|

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
# Blocks that span only one line usually use the braces form
objs.method \_\_ |obj| do_something \_\_
A

{ }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
objs.method \_\_\_ |obj|
  # do first line
  # do second line
  # ...
  # do nth line
end
A

do

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
objs.method do \_\_\_
  # do first line
  # do second line
  # ...
  # do nth line
end
A

|obj|

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
objs.method do |obj|
  # do first line
  # do second line
  # ...
  # do nth line
\_\_\_
A

end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

x __y // returns true if two things are equal

A

==

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

x__y // returns true if two things are not equal

A

!=

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

x __ y // returns true if x is less than or equal to y

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

x __ y // returns true if x is greater than or equal to y

A

> =

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

__
comment line
comment line
=end

A

=begin

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

=begin
comment line
comment line
__

A

=end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

empty_hash = Hash.new
=> {}

my_hash = Hash.new(“The Default”)
my_hash[“random_key”]
=>__

A

“The Default”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

empty_hash = Hash.new
=> {}

my_hash = Hash.new(“The Default”)
my_hash[“random_key”]
=>__

A

“The Default”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q
\_\_\_\_ do |arg|
  # Do something to each element, referenced as arg
end
A

array.each

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

array.each ___ |arg|
# Do something to each element, referenced as arg
end

A

do

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q
array.each do \_\_\_\_
  # Do something to each element, referenced as arg
end
A

|arg|

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q
array.each do |arg|
  # Do something to each element, referenced as arg
\_\_\_\_
A

end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

[[1,2,3], [4,5,6], 7, [[8,9], 10]].____

=> [1,2,3,4,5,6,7,8,9,10]

A

flatten

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

[1,1,1,2,3,4,3,3].___

=> [1,2,3,4]

A

uniq

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q
# Blocks that span only one line usually use the braces form
objs.\_\_\_ { |obj| do_something }
A

method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q
# Blocks that span only one line usually use the braces form
objs.method {\_\_\_ do_something }
A

|obj|

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q
# Blocks that span only one line usually use the braces form
objs.method \_\_ |obj| do_something \_\_
A

{ }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q
objs.method \_\_\_ |obj|
  # do first line
  # do second line
  # ...
  # do nth line
end
A

do

33
Q
objs.method do \_\_\_
  # do first line
  # do second line
  # ...
  # do nth line
end
A

|obj|

34
Q
objs.method do |obj|
  # do first line
  # do second line
  # ...
  # do nth line
\_\_\_
A

end

35
Q

x __y // returns true if two things are equal

A

==

36
Q

x__y // returns true if two things are not equal

A

!=

37
Q

x __ y // returns true if x is less than or equal to y

A
38
Q

x __ y // returns true if x is greater than or equal to y

A

> =

39
Q

__
comment line
comment line
=end

A

=begin

40
Q

=begin
comment line
comment line
__

A

=end

41
Q
# Hash.new constructor
my_hash = \_\_\_([default_value])
A

Hash.new

42
Q

empty_hash = Hash.new
=> {}

my_hash = Hash.new(“The Default”)
my_hash[“random_key”]
=>__

A

“The Default”

43
Q
# Hash literal notation
my_hash = {
  \_\_ => value1,
  :key2  => value2,
  3 => value 3
}
A

“key1”

44
Q
# Hash literal notation
my_hash = {
  "key1" => value1,
  :key2  => value2,
  3 => value 3
}
A

:key2

45
Q
# Hash literal notation
my_hash = {
  "key1" => value1,
  :key2  => value2,
  \_\_ => value 3
}
A

3

46
Q

my_hash = {
__
}

A

key1: value1,
key2: value2

47
Q

if ___
puts “I get printed!”
end

I get printed!

A

true

48
Q

___ false
puts “I get printed!”
end

I get printed!

A

unless

49
Q
x = 5
if x > 5
  print "I am big!"
\_\_\_ x == 5
  print "I am medium!"
else
  print "I am small!"
end

I am medium!

A

elsif

50
Q
x = 5
if x > 5
  print "I am big!"
elsif x == 5
  print "I am medium!"
\_\_\_
  print "I am small!"
end

I am medium!

A

else

51
Q

i = 1

___ i

A

while

52
Q

counter = 3

___ counter

A

until

53
Q

__ number in (0..5)
puts number
end

0
1
2
3
4
5
A

for

54
Q

for number __ (0..5)
puts number
end

0
1
2
3
4
5
A

in

55
Q

my_array = [“Matz”, “chunky”, “bacon”]
for item in __
puts item
end

Matz
chunky
bacon

A

my_array

56
Q

10 __ 3

=> 1

A

%

57
Q

9.99.___

=> 9

A

floor

58
Q

45.4.___
=> 46

(4 - 1.9).___
=> 3

A

ceil

59
Q

__

=> 3.14159265358979

A

Math::PI

60
Q

___(100)
=> 10.0

___(5+4)
=> 3.0

A

Math.sqrt

61
Q

___ sum(x,y)
x + y
end

sum(13, 379)
=> 392

A

def

62
Q

3.times { ___ “Hello!” }

Hello!Hello!Hello!

A

print

63
Q

3.times { ___ “Hello!” }
Hello!
Hello!
Hello!

A

puts

64
Q
a = ["4"]
\_\_\_ a
when 1..4, 5
  puts "It's between 1 and 5"
when 6
  puts "It's 6"
when String
  puts "You passed a string"
else
  puts "You gave me #{a} -- I have no idea what to do with that."
end

=> You gave me 4 – I have no idea what to do with that.

A

case

65
Q
a = ["4"]
case a
\_\_\_ 1..4, 5
  puts "It's between 1 and 5"
\_\_\_ 6
  puts "It's 6"
\_\_\_ String
  puts "You passed a string"
else
  puts "You gave me #{a} -- I have no idea what to do with that."
end

=> You gave me 4 – I have no idea what to do with that.

A

when

66
Q
a = ["4"]
case a
when 1..4, 5
  puts "It's between 1 and 5"
when 6
  puts "It's 6"
when String
  puts "You passed a string"
\_\_\_
  puts "You gave me #{a} -- I have no idea what to do with that."
end

=> You gave me 4 – I have no idea what to do with that.

A

else

67
Q

grade = 88
status = grade >= 70 ___ “pass” : “fail”
=> pass

A

?

68
Q

grade = 88
status = grade >= 70 ? “pass”___ “fail”
=> pass

A

:

69
Q

ne_to_ten = (1..10).to_a
one_to_ten.___ do |num|
print (num**2).to_s + “ “
end

1 4 9 16 25 36 49 64 81 100

A

each

70
Q

ne_to_ten = (1..10).to_a
one_to_ten.each ___ |num|
print (num**2).to_s + “ “
end

1 4 9 16 25 36 49 64 81 100

A

do

71
Q

3.____ do
puts “I’m in the loop!”
end
puts “I’m out the loop!”

A

times

72
Q

3.times ____
puts “I’m in the loop!”
end
puts “I’m out the loop!”

A

do

73
Q

空のハッシュを作成

scores = ____

A

{}

74
Q
# キー"Alice"、値80のペアを追加
scores\_\_\_\_ = 80
A

[“Alice”]

75
Q
# キー"Alice"、値80のペアを追加
scores["Alice"] \_\_\_
A

= 80

76
Q
# キー"Alice"の値を取り出し
p scores\_\_\_\_
A

[“Alice”]

77
Q
# 3つのキー(name, email, address)+値からなるハッシュを作成
user = { \_\_\_ => "k-sato", \_\_\_ => "k-sato@foo.xx.jp",
         \_\_\_ => "Tokyo" }
A

:name :email :address

78
Q
# キー:nameの値を取り出し
p user\_\_\_
A

[:name]