Skip to content

feat: add select primitive with tests - #3

Draft
thejhh wants to merge 1 commit into
mainfrom
feature/select-primitive
Draft

feat: add select primitive with tests#3
thejhh wants to merge 1 commit into
mainfrom
feature/select-primitive

Conversation

@thejhh

Copy link
Copy Markdown
Contributor

No description provided.

@thejhhthejhh left a comment

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
ContributorAuthor

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

Comment threaddocs/select-syntax.md Outdated
@@ -0,0 +1,38 @@
The `select` operation chooses between two values based on a simple string

Copy link
Copy Markdown
ContributorAuthor

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

@thejhhthejhh linked an issue May 9, 2025 that may be closed by this pull request
@thejhh
thejhhforce-pushed the feature/select-primitive branch from da92051 to 2423c35CompareMay 9, 2025 17:08
@thejhh
thejhhforce-pushed the feature/select-primitive branch 6 times, most recently from b6db0d4 to 77e32bbCompareMay 19, 2025 09:01
@thejhh
thejhhforce-pushed the feature/select-primitive branch from 77e32bb to cff7942CompareMay 19, 2025 09:04
@thejhh
thejhh marked this pull request as draft May 21, 2025 16:08
Sign up for freeto 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

@thejhh