MY NAME IS BOND! JAMES BOND!

def scream!(string) string.upcase! end names = ['James Bond', 'Blofeld', 'M', 'Strawberry Fields'] names.each do |name| puts scream!(name) end
This code logs:

JAMES BOND
BLOFELD

STRAWBERRY FIELDS

Why is M missing?

1 Response

Unlike #upcase, #upcase! returns nil if no changes are made to calling string object and puts nil returns an empty string

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.