-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTuesdayWeek2
More file actions
52 lines (26 loc) · 1.61 KB
/
TuesdayWeek2
File metadata and controls
52 lines (26 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
1. What alternative keyword can we use if we're negating the boolean expression inside our if?
- Unless.
2. What is the 'negative doppleganger' for while?
- Until.
3. What is a "modifier form" of an expression? (Which I call a post-conditional)
- The same expression collapsed into a single line for clutter free and more readable programming.
4. What does a case statement return by default?
- Nil.
5. What two values evaluate to false inside and If?
- False and nil.
6. What is a ternary expression used for (?:)?
- As a compact if statement.
7. What is a “guarded or” used for (||=)?
- Same as || but it reduces the length of the expression and you don't to repeat the name of the variable.
8. What’s the fastest way to make an array of words?
- %w{ one two three} Used only if non of the strings have embedded spaces.
9. When using symbols as Hash keys, what are the two ways to initialize a Hash using the curly brace notation? (1.9 hash syntax)
- hash = { :one => 'hello', :two => 'hi' } and hash ={ one: 'hello', two: 'hi' }
10. What is the name of the * operator?
- Multiplication, (asterisk, starred parameter/argument)?
11. Should you use a for loop to iterate over an Array or Hash? If not, what’s the alternative?
- No. each method
12. What is the difference between each and map?
- Map does not make a decision based on the return from the block instead it creates a new array containing everything the block returned in order.
13. What is a bang method?
- A method that ends with an exclamation point, which permanently modifies an object in-place. A way of saying: "beware, this method is dangerous".