Glossary Flashcards

(78 cards)

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
``` array.each do ____ # Do something to each element, referenced as arg end ```
|arg|
26
``` array.each do |arg| # Do something to each element, referenced as arg ____ ```
end
27
[[1,2,3], [4,5,6], 7, [[8,9], 10]].____ | => [1,2,3,4,5,6,7,8,9,10]
flatten
28
[1,1,1,2,3,4,3,3].___ | => [1,2,3,4]
uniq
29
``` # Blocks that span only one line usually use the braces form objs.___ { |obj| do_something } ```
method
30
``` # Blocks that span only one line usually use the braces form objs.method {___ do_something } ```
|obj|
31
``` # Blocks that span only one line usually use the braces form objs.method __ |obj| do_something __ ```
{ }
32
``` objs.method ___ |obj| # do first line # do second line # ... # do nth line end ```
do
33
``` objs.method do ___ # do first line # do second line # ... # do nth line end ```
|obj|
34
``` objs.method do |obj| # do first line # do second line # ... # do nth line ___ ```
end
35
x __y // returns true if two things are equal
==
36
x__y // returns true if two things are not equal
!=
37
x __ y // returns true if x is less than or equal to y
38
x __ y // returns true if x is greater than or equal to y
>=
39
__ comment line comment line =end
=begin
40
=begin comment line comment line __
=end
41
``` # Hash.new constructor my_hash = ___([default_value]) ```
Hash.new
42
empty_hash = Hash.new => {} my_hash = Hash.new("The Default") my_hash["random_key"] =>__
"The Default"
43
``` # Hash literal notation my_hash = { __ => value1, :key2 => value2, 3 => value 3 } ```
"key1"
44
``` # Hash literal notation my_hash = { "key1" => value1, :key2 => value2, 3 => value 3 } ```
:key2
45
``` # Hash literal notation my_hash = { "key1" => value1, :key2 => value2, __ => value 3 } ```
3
46
my_hash = { __ }
key1: value1, key2: value2
47
if ___ puts "I get printed!" end I get printed!
true
48
___ false puts "I get printed!" end I get printed!
unless
49
``` x = 5 if x > 5 print "I am big!" ___ x == 5 print "I am medium!" else print "I am small!" end ``` I am medium!
elsif
50
``` x = 5 if x > 5 print "I am big!" elsif x == 5 print "I am medium!" ___ print "I am small!" end ``` I am medium!
else
51
i = 1 | ___ i
while
52
counter = 3 | ___ counter
until
53
__ number in (0..5) puts number end ``` 0 1 2 3 4 5 ```
for
54
for number __ (0..5) puts number end ``` 0 1 2 3 4 5 ```
in
55
my_array = ["Matz", "chunky", "bacon"] for item in __ puts item end Matz chunky bacon
my_array
56
10 __ 3 | => 1
%
57
9.99.___ | => 9
floor
58
45.4.___ => 46 (4 - 1.9).___ => 3
ceil
59
__ | => 3.14159265358979
Math::PI
60
___(100) => 10.0 ___(5+4) => 3.0
Math.sqrt
61
___ sum(x,y) x + y end sum(13, 379) => 392
def
62
3.times { ___ "Hello!" } | Hello!Hello!Hello!
print
63
3.times { ___ "Hello!" } Hello! Hello! Hello!
puts
64
``` 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.
case
65
``` 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.
when
66
``` 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.
else
67
grade = 88 status = grade >= 70 ___ "pass" : "fail" => pass
?
68
grade = 88 status = grade >= 70 ? "pass"___ "fail" => pass
:
69
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
each
70
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
do
71
3.____ do puts "I'm in the loop!" end puts "I'm out the loop!"
times
72
3.times ____ puts "I'm in the loop!" end puts "I'm out the loop!"
do
73
空のハッシュを作成 | scores = ____
{}
74
``` # キー"Alice"、値80のペアを追加 scores____ = 80 ```
["Alice"]
75
``` # キー"Alice"、値80のペアを追加 scores["Alice"] ___ ```
= 80
76
``` # キー"Alice"の値を取り出し p scores____ ```
["Alice"]
77
``` # 3つのキー(name, email, address)+値からなるハッシュを作成 user = { ___ => "k-sato", ___ => "k-sato@foo.xx.jp", ___ => "Tokyo" } ```
:name :email :address
78
``` # キー:nameの値を取り出し p user___ ```
[:name]