HELP: interpolate
{ $values { "str" string } }
{ $description "String interpolation using named variables and/or stack arguments, writing to the " { $link output-stream } "." }
+{ $notes "Stack arguments are numbered from the top of the stack." }
{ $examples
{ $example
"USING: interpolate ;"
- "\"Bob\" \"Alice\" \"Hi ${0}, it's ${1}.\" interpolate"
+ "\"Bob\" \"Alice\" \"Hi ${1}, it's ${0}.\" interpolate"
"Hi Bob, it's Alice."
}
{ $example
HELP: interpolate>string
{ $values { "str" string } { "newstr" string } }
-{ $description "String interpolation using named variables and/or stack arguments, captured as a " { $link string } "." } ;
+{ $description "String interpolation using named variables and/or stack arguments, captured as a " { $link string } "." }
+{ $notes "Stack arguments are numbered from the top of the stack." } ;
{ interpolate interpolate>string } related-words
USING: interpolate io.streams.string namespaces tools.test locals ;
IN: interpolate.tests
-{ "A B" } [ "A" "B" "${0} ${1}" interpolate>string ] unit-test
-{ "B A" } [ "A" "B" "${1} ${0}" interpolate>string ] unit-test
-{ "C A" } [ "A" "B" "C" "${2} ${0}" interpolate>string ] unit-test
+{ "A B" } [ "A" "B" "${1} ${0}" interpolate>string ] unit-test
+{ "B A" } [ "A" "B" "${0} ${1}" interpolate>string ] unit-test
+{ "C A" } [ "A" "B" "C" "${0} ${2}" interpolate>string ] unit-test
{ "Hello, Jane." } [
"Jane" "name" set