A difference between printing new line with lists than the normal behavior

Hello

list = 1:5        # list = [1,2,3,4,5]
see list + nl
In the previous example newline will be added to the list then the list will be printed, the default print of the lists will print a newline at the end, you added new newline and you have now 2 newlines to be printed.
See <Expr>
The see command just print the final result of the expression, the expression will be evaluated as it
nl = char(13) + char(10) # just a variable that you can change to anything !
The + is an operator
string + string ---> new string
string + number ---> new string
number + number ---> new number
number + string ---> new number
list + item ---> nothing new will be created but the item will be added to the same list
Exception
number + nl —> New String
This exception is added to easily print numbers + new line.
No need for this with printing lists because after printing the last item we already get a new line.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s