Control flow Flashcards

1
Q

simple ruby control flow.

A
if condition
  block
elsif condition
  block
else 
  block
end
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

test if value is false.

A

unless

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

check if 2 values are equal.

A

==

it should be double equal sign because one equal is used for assignment.

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

check if 2 values are not equal.

A

!=

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

the logical or boolean operators.

A

&&&raquo_space; and
||&raquo_space; or
!&raquo_space; not

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

only returns true when both sides are true.

A

&&

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

returns true if any of the side is true.

A

||

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

turns true value false and vice versa.

A
!
ex.
!true 
>> false
!(700 / 10 == 70)
>> false
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

a method that evaluates to true if find a string inside a string.

A

include
ex.
“I am the guru”.include? “g”
» true

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

what does the method that end with “?” evaluate to?

A
boolean
ex.
include?
blank?
empty?
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How to replace letters in string?

A

gsub
ex.
string_to_change.gsub!(/s/, “th”)

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

give an example of the case conditional statement.

A
case language
when "JS"
  puts "Websites"
when "Python"
  puts "Science"
when "Ruby"
  puts "Web applications"
else
  puts "I don't know"
end
How well did you know this?
1
Not at all
2
3
4
5
Perfectly