String joining

From Cuis CookBook
Jump to navigation Jump to search

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.