Logo

Programming-Idioms

History of Idiom 3 > diff from v21 to v22

Edit summary for version 22 by steenslag:
[Ruby] p method (and thus the finish method) returned a string

Version 21

2016-02-18, 16:57:55

Version 22

2016-04-18, 20:10:56

Idiom #3 Create a procedure

Like a function which doesn't return any value, thus has only side effects (e.g. Print to standard output)

Idiom #3 Create a procedure

Like a function which doesn't return any value, thus has only side effects (e.g. Print to standard output)

Code
def finish( name )
	p "My job here is done. Goodbye #{name}"
end
Code
def finish( name )
  puts "My job here is done. Goodbye #{name}"
end
Comments bubble
It is faster than p "My job here is done. Goodbye " + name.

Comments bubble
Ruby methods always return something; in this case nil, the return value of puts