Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Support $cond and $select in expressions (or termary) #156

Closed
@esprehn

Description

@esprehn

Often you want to choose two things based on a predicate but there's no ternary operator so people just hack around it with {true: 'value1', false: 'value2'}[!!checkFunction()] which is far less readable.

Support:

$cond(checkFunction(), 'value1', 'value2')
$select(keyFunction(), {key1:'value1', key2: 'value2'})

Supporting a true ternary operator makes conditional function calls a little too easy, but supporting function forms of the operations means you get the same end result without that problem.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions