Sha256: 69371380db8717e6f4c6c34533c4cc090b95b48d8a59ccb42e2f838ef10f706f

Contents?: true

Size: 632 Bytes

Versions: 11

Compression:

Stored size: 632 Bytes

Contents

The intent was to return nil when the first value was nil.
That was the op's issue.
If one of the values was nil, she/he wanted nil.

Nil && anything_else will always return nil, and I will not evaluate the
second clause.


> >>>>>>>>
> It should be:
>     2.0 && 2.0 + 12.0
> <<<<<<<<<
>
> Ah! Yes, that works.
>
>
People are intent on not understanding, aren't they.

    def nil_add_12 f
      f && f + 12.0
    end

Generalised to two parameters:

    def nil_add a, b
      a && b && a + b
    end

The only quirk is the way they handle `false`.

This is not tested, but it may be possible to do this, too:

    f&.+ b

Cheers

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
email_reply_trimmer-0.2.0 test/trimmed/embedded_email_17.txt
runger_email_reply_trimmer-0.3.0 test/trimmed/embedded_email_17.txt
runger_email_reply_trimmer-0.2.2 test/trimmed/embedded_email_17.txt
runger_email_reply_trimmer-0.2.1 test/trimmed/embedded_email_17.txt
email_reply_trimmer-0.1.13 test/trimmed/embedded_email_17.txt
email_reply_trimmer-0.1.12 test/trimmed/embedded_email_17.txt
email_reply_trimmer-0.1.11 test/trimmed/embedded_email_17.txt
email_reply_trimmer-0.1.10 test/trimmed/embedded_email_17.txt
email_reply_trimmer-0.1.9 test/trimmed/embedded_email_17.txt
email_reply_trimmer-0.1.8 test/trimmed/embedded_email_17.txt
email_reply_trimmer-0.1.7 test/trimmed/embedded_email_17.txt