Skip to Main Content
Learn to Program, 2nd Edition
book

Learn to Program, 2nd Edition

by Chris Pine
March 2009
Intermediate to advanced content levelIntermediate to advanced
194 pages
4h
English
Pragmatic Bookshelf
Content preview from Learn to Program, 2nd Edition

Exercises from Chapter 6

Angry Boss

How you could do it:

puts ​'CAN​\'​T YOU SEE I​\'​M BUSY?! MAKE IT FAST, JOHNSON!'
request = gets.chomp
puts ​'WHADDAYA MEAN "'​ + request.upcase + ​'"?!? YOU​\'​RE FIRED!!'
<= CAN'T YOU SEE I'M BUSY?! MAKE IT FAST, JOHNSON!
=> I want a raise
<= WHADDAYA MEAN "I WANT A RAISE"?!? YOU'RE FIRED!!

How I would do it:

names = [​'johnson'​, ​'smith'​, ​'weinberg'​, ​'filmore'​]
puts ​"CAN'T YOU SEE I'M BUSY?! MAKE IT FAST, ​#{names[rand(4)].upcase}​!"
request = gets.chomp
puts ​"WHADDAYA MEAN ​\"#{request.upcase}\"​?!? YOU'RE FIRED!!"
<= CAN'T YOU SEE I'M BUSY?! MAKE IT FAST, FILMORE!
=> I quit
<= WHADDAYA MEAN "I QUIT"?!? YOU'RE FIRED!!

Table of Contents

How you could do it:

title = ​'Table of Contents'​.center(50)
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learn to Program, 3rd Edition

Learn to Program, 3rd Edition

Chris Pine
The Book of Ruby

The Book of Ruby

Huw Collingbourne

Publisher Resources

ISBN: 9781680500172Errata