Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Don't Get Clever

avdi
July 20, 2013
230

Don't Get Clever

Part of the Ruby Rogues live panel episode at Lone Star Ruby Conference 2013.

avdi

July 20, 2013
Tweet

Transcript

  1. Don't Get Clever
    Avdi Grimm

    View Slide

  2. Pop quiz
    r
    e
    q
    u
    i
    r
    e '
    p
    s
    t
    o
    r
    e
    '
    s
    t
    o
    r
    e = P
    S
    t
    o
    r
    e
    .
    n
    e
    w
    (
    '
    d
    a
    t
    a
    .
    p
    s
    t
    o
    r
    e
    '
    )
    s
    t
    o
    r
    e
    .
    t
    r
    a
    n
    s
    a
    c
    t
    i
    o
    n
    (
    t
    r
    u
    e
    ) d
    o
    # .
    .
    .
    e
    n
    d

    View Slide

  3. Pop quiz 2
    A
    r
    r
    a
    y
    .
    i
    n
    s
    t
    a
    n
    c
    e
    _
    m
    e
    t
    h
    o
    d
    s
    (
    f
    a
    l
    s
    e
    )

    View Slide

  4. Symbols are truthy
    r
    e
    q
    u
    i
    r
    e '
    p
    s
    t
    o
    r
    e
    '
    s
    t
    o
    r
    e = P
    S
    t
    o
    r
    e
    .
    n
    e
    w
    (
    '
    d
    a
    t
    a
    .
    p
    s
    t
    o
    r
    e
    '
    )
    s
    t
    o
    r
    e
    .
    t
    r
    a
    n
    s
    a
    c
    t
    i
    o
    n
    (
    :
    r
    e
    a
    d
    _
    o
    n
    l
    y
    ) d
    o
    # .
    .
    .
    e
    n
    d

    View Slide

  5. Clever!

    View Slide

  6. What's :
    r
    e
    a
    d
    _
    o
    n
    l
    y
    ??
    s
    t
    o
    r
    e
    .
    t
    r
    a
    n
    s
    a
    c
    t
    i
    o
    n
    (
    :
    r
    e
    a
    d
    _
    o
    n
    l
    y
    ) d
    o
    # .
    .
    .
    e
    n
    d

    View Slide

  7. Dead end
    s
    t
    o
    r
    e
    .
    t
    r
    a
    n
    s
    a
    c
    t
    i
    o
    n
    (
    :
    c
    h
    u
    n
    k
    y
    _
    b
    a
    c
    o
    n
    ) d
    o
    # .
    .
    .
    e
    n
    d

    View Slide

  8. Negation
    A
    r
    r
    a
    y
    .
    i
    n
    s
    t
    a
    n
    c
    e
    _
    m
    e
    t
    h
    o
    d
    s
    (
    !
    :
    i
    n
    c
    l
    u
    d
    e
    _
    s
    u
    p
    e
    r
    )

    View Slide

  9. Don't get clever

    View Slide

  10. Intention-revealing argument
    r
    e
    a
    d
    _
    o
    n
    l
    y = t
    r
    u
    e
    s
    t
    o
    r
    e
    .
    t
    r
    a
    n
    s
    a
    c
    t
    i
    o
    n
    (
    r
    e
    a
    d
    _
    o
    n
    l
    y
    ) d
    o
    # .
    .
    .
    e
    n
    d

    View Slide

  11. Intention-revealing argument
    i
    n
    c
    l
    u
    d
    e
    _
    s
    u
    p
    e
    r = f
    a
    l
    s
    e
    A
    r
    r
    a
    y
    .
    i
    n
    s
    t
    a
    n
    c
    e
    _
    m
    e
    t
    h
    o
    d
    s
    (
    i
    n
    c
    l
    u
    d
    e
    _
    s
    u
    p
    e
    r
    )

    View Slide

  12. Inline version
    A
    r
    r
    a
    y
    .
    i
    n
    s
    t
    a
    n
    c
    e
    _
    m
    e
    t
    h
    o
    d
    s
    (
    i
    n
    c
    l
    u
    d
    e
    _
    s
    u
    p
    e
    r = f
    a
    l
    s
    e
    )

    View Slide

  13. Don't get clever

    View Slide