Debian Codegraph @

testdata/reply/embedded_email_17.txt

raw
1 The intent was to return nil when the first value was nil.
2 That was the op's issue.
3 If one of the values was nil, she/he wanted nil.
4
5 Nil && anything_else will always return nil, and I will not evaluate the
6 second clause.
7
8
9 > >>>>>>>>
10 > It should be:
11 > 2.0 && 2.0 + 12.0
12 > <<<<<<<<<
13 >
14 > Ah! Yes, that works.
15 >
16 >
17 People are intent on not understanding, aren't they.
18
19 def nil_add_12 f
20 f && f + 12.0
21 end
22
23 Generalised to two parameters:
24
25 def nil_add a, b
26 a && b && a + b
27 end
28
29 The only quirk is the way they handle `false`.
30
31 This is not tested, but it may be possible to do this, too:
32
33 f&.+ b
34
35 Cheers