Sequence on variable/value
- Dominant language
- C#
- Stars
- 4.9k
- Forks
- 540
- PR merge metrics
- No merged PRs in 30d
Description
Ink has some pretty powerful mechanisms, but I'm missing one construct that I found very useful for writing texts with variables in my own scripting language. An example:
```
He brought me [# number | nothing! The cad|one calling bird|two french hens|three turtle doves|an aviary#].
```
This simple returns the first element in the construct if number is <= 0 (or false), the last element in the construct if number >= maximum elements, and the appropriate value if number is a valid index in the sequence.
E.g.,, for number = 0, you get:
He brought me nothing! The cad.
For number = 2, you get:
He brought me two french hens.
For numbers >= 4 you get:
He brought me an aviary.
You have something a little similar in your inline if-then `{ val : text1 | text0 }`, but that's of course not as powerful (`[# #]` started out as a similar construct, before I decided to flip the order and generalize it), and I haven't noticed anything that provides the same functionality.
Perhaps I missed something? How do you handle that kind of variable-dependent writing in-line today?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.