A new line in the creak

I want to do something like this: Transcript show: '\ n'. as?

+5
source share
3 answers

Use the following:

Transcript cr

You can use it after the value through the cascade:

Transcript show: 123; cr
+9
source

The symbol itself can be reached as Character cr. So you can also do this:

Transcript show: 'Bla! , Character cr asString.

But of course,

Transcript show: 'Bla!' ; cr.

is more elegant.

+4
source

() , Smalltalk. cr, tab .. .

, , ( "streamContents:" "withCRs" newLine). , () . , VisualWorks Smalltalk/X ( ):

'someString with newline<n>and<t>tabs' expandMacros

or even with a printf-like slice of other printStrings objects:

'anotherString<n><t>with newlines<n>and<t>tabs and<p>' expandMacrosWith:(Float pi)

I think there is something similar in Squeak and V'Age.

But keep in mind: these extensions are executed at runtime. Thus, you may encounter a penalty by heavily using them in many lines.

+4
source

All Articles