ϊʔυͷछྨҐஔใ͕ඞཁ 10.times {|i| i + 1 } var = i + 1 10.times {|i| var } i + 1 Λ var Ͱஔ͖͑Δ var = i + 1 Λ1ߦ্ʹՃ 10.times {|i| i + 1 } 10.times {|i| var = i + 1; var } i + 1 Λ var Ͱஔ͖͑Δ var = i + 1 ΛલʹՃ ⭕ ❌
# @obj can be nil until # #compute is called @obj&.count || 0 end def count # Default value is 0 @obj&.count || 0 end def count # @obj can be nil until # #compute is called var = @obj&.count var || 0 end def count var = @obj&.count # Default value is 0 var || 0 end
end end if condition_a action_a elsif condition_b if condition_b action_b else action_c end end if condition_a action_a elsif condition_b action_b action_b else action_c end end if condition_a action_a elsif condition_b action_b action_b else action_c end if condition_a action_a elsif condition_b action_b else action_c end 1. elseΛelsif 2. if condition_b Λআ 3. ༨ͳendΛ আ 4.ॏෳ͍ͯ͠Δaction_b Λআ
action_b end if condition_a action_a action_b end elseΛআ if condition_a action_a else action_b end if condition_a action_a elsif action_b end elsifʹஔ
if condition_b action_b else action_c end end if condition_a action_a elsif condition_b if condition_b action_b else action_c end end if condition_a action_a elsif condition_b action_b action_b else action_c end end if condition_a action_a elsif condition_b action_b action_b else action_c end if condition_a action_a elsif condition_b action_b else action_c end 1. elseΛelsif 2. if condition_b Λআ 3. ༨ͳendΛ আ 4.ॏෳ͍ͯ͠Δaction_b Λআ
Ifͷ͋ͱͷۭനifʹଐ͢Δ (ϧʔϧ1) • action_a લͷվߦͱ2ͭͷۭനΛͭ (ϧʔϧ1&2) • endલͷվߦΛͭ (ϧʔϧ1&2) if cond\n action_a\n end if cond\n action_a\n end if cond\n action_a\n end
because those were the whiteboard marker colours we used to draw the data structure in the design meeting. There's no other meaning to the colours. • σʔλߏʹ͍͍ͭͯٞͯ͠Δ࣌ʹ͍ͬͯͨϚʔΧʔ͕ͱͩͬ ͨɻͦΕҎ্ͷཧ༝ͳ͍ɻ
0 IF o ff set: 0 NODE_IF o ff set: 30 condition_a o ff set: 3 action_a o ff set: 14 NODE_ELSE o ff set: 25 END o ff set: 86 ELSE o ff set: 25 IF o ff set: 30 condition_b o ff set: 35 action_b o ff set: 46 -> 47 END o ff set: 79 NODE_ELSE o ff set: 59 action_c o ff set: 66 ELSE o ff set: 59