inkle / inkle/ink

Sequence on variable/value

Open
#57 9 comments 0 reactions 0 assignees View on GitHub
enhancement
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.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.