Skip to content

Conversation

@thejhh
Copy link
Contributor

@thejhh thejhh commented May 7, 2025

No description provided.

Copy link
Contributor Author

@thejhh thejhh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requires work

return nil, fmt.Errorf("select expects exactly 3 arguments (condition, trueValue, falseValue), got %d", len(args))
}

condition := fmt.Sprintf("%v", args[0])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be case insensitive

@@ -0,0 +1,38 @@
The `select` operation chooses between two values based on a simple string
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we support quite a lot of different types, I think we shouldn't just expect a string.

We should support:

  • If an array, empty array is false, otherwise true.
  • If null, it is false
  • If an empty string, it should be false
  • If boolean, a boolean
  • Of a function/operation/subroutine, the result of calling it
  • If an object, true
  • If a promise, we should wait for it and use the result
  • ...

We would also need equals and other new primitives

@thejhh thejhh linked an issue May 9, 2025 that may be closed by this pull request
@thejhh thejhh force-pushed the feature/select-primitive branch from da92051 to 2423c35 Compare May 9, 2025 17:08
@thejhh thejhh force-pushed the feature/select-primitive branch 6 times, most recently from b6db0d4 to 77e32bb Compare May 19, 2025 09:01
@thejhh thejhh force-pushed the feature/select-primitive branch from 77e32bb to cff7942 Compare May 19, 2025 09:04
@thejhh thejhh marked this pull request as draft May 21, 2025 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Primitive select

1 participant