string formatting in FS?
adamohern
Member, OS Professional Posts: 216 PRO
I'm used to Python's string formatting, where I can insert variables into a longer string and the result is concatenated automatically. Is there anything similar in FS? In the example below, look how much more readable the Python example is.
Python:
Python:
"Hello, my name is %s and I like to eat %s on %s." % (name, food, day_of_week)or
"Hello, my name is {} and I like to eat {} on {}.".format(name, food, day_of_week)
vs FeatureScript (AFAIK):
"Hello, my name is " ~ name ~ " and I like to eat " ~ food ~ " on " ~ day_of_week ~ "."
0
Comments
-
There isn't right now. I suspect at some point the FS solution for this will look a lot like sprintf in C... something like:
format("%d plus %d is %d", a, b, a+b);This is NOT available today – your quotes and twiddles solution is currently the only way to go.1 -
Any updates on that issue?
0 -
@florian_neurohr not that I'm aware of. You still have to use ~ to join strings. There are some useful new regex() functions though.
▚▞▚▞▚▞▚▞▚0 -
If you just wanted to join an array of strings with a delimiter, there's a
joinfunction. Otherwise, yeah, no out-of-the-box solution.0




