String joining: Difference between revisions
Jump to navigation
Jump to search
(importe material) |
(hili) |
||
Line 1: | Line 1: | ||
== Case 1. Comma Join == |
== Case 1. Comma Join == |
||
'''Example''' |
'''Example'''<syntaxhighlight lang="smalltalk"> |
||
". simplest case " |
|||
'hello', ' world' . "=> 'hello world' " |
|||
</syntaxhighlight><syntaxhighlight lang="smalltalk"> |
|||
⚫ | |||
⚫ | |||
</syntaxhighlight><syntaxhighlight lang="smalltalk"> |
|||
⚫ | |||
⚫ | |||
</syntaxhighlight> |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
== Case 2. Join the elements of an array into a string == |
== Case 2. Join the elements of an array into a string == |
Revision as of 09:56, 5 May 2025
Case 1. Comma Join
Example
". simplest case "
'hello', ' world' . "=> 'hello world' "
". more elements "
'hello', ' world', ', good day !'. "=> 'hello world, good day !' "
". conversion to string is needed in comma joins "
'hello', ' world' , ' it is n.' , 3 asString, ' times i say it'. "=> 'hello world it is n.3 times i say it' "
Case 2. Join the elements of an array into a string
Example
". simplest case" ' ' join: #('hello' 'world'). "=> 'hello world' " ". showing toString auto-conversion " ' ' join: #('hello, this is value: ' 123). "=> 'hello, this is value: 123' " ". joiner is not only a space, the case of CSV file production " ', ' join: #('name' 'last name' 'email'). "=> 'name, last name, email' " ', ' join: #('nicola' 'mingotti' 'foobar@gmail.com'). "=> 'nicola, mingotti, foobar@gmail.com' "
Dr. Nicola Mingotti first wrote this on 22-Sep-2021. Tested in Cuis5.0-4871.image.