Operator Examples Flashcards

Name the operator and description

You may prefer our related Brainscape-certified flashcards:
1
Q

2 + 4 == 6

A

+: Add

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

2 - 4 == 2

A

-: Subtract

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

2 * 4 == 8

A

*: Multiply

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

2 ** 4 == 16

A

**: Power of

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

2 / 4.0 == 0.5

A

/: Divide

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

2 % 4 == 2

A

%: Modulus

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

4 > 4 == false

A

>: Greater than

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

“1”.to_i == 1

A

.: Dot access

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

Module::Class

A

::- Colon access

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

[1,2,3,4]

A

[]: List brackets

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

!true == false

A

!: Not

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

4 < 4 == false

A

<: Less than

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

4 > 4 == false

A

>: Greater than

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

4 >= 4 == true

A

<=: Greater than equal

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

4 <= 4 == true

A

>=: Less than equal

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

4 4 == 0

A

: Comparison

17
Q

4 == 4 == true

A

==: Equal

18
Q

4 === 4 === true

A

===: Equality

19
Q

4 != 4 == false

A

!=: Not equal

20
Q

true && false == false

A

&&: Logical and (higher precedence)

21
Q

true || false == true

A

||: Logical or (higher precedence)

22
Q

(0..3).to_a == [0, 1, 2, 3]

A

..: Range inclusive

23
Q

(0…3).to_a == [0, 1, 2]

A

…: Range non-inclusive

24
Q

$stdin

A

$: Global scope

25
Q

@var ; @@classvar

A

@: Object scope

26
Q

@var; @@classvar

A

@@: Class scope