pallikara's programming + politics + philosophy potpourri
Programming Ruby: The Pragmatic Programmer's Guide:
"a hash by default returns nil when indexed by a key it doesn't contain. Normally this is convenient, as nil means false when used in conditional expressions. Sometimes you'll want to change this default. For example, if you're using a hash to count the number of times each key occurs, it's convenient to have the default value be zero. This is easily done by specifying a default value when you create a new, empty hash.
histogram = Hash.new(0)
histogram['key1'] » 0
histogram['key1'] = histogram['key1'] + 1
histogram['key1'] » 1"
Indeed, an award should go to the Virgin Airlines gate attendant in Sydney some
months ago for being smart and funny, while making her point, when confronted
with a passenger who probably deserved to fly as cargo.
A crowded Virgin flight was cancelled after Virgin's 767s had been Withdrawn
from service. A single attendant was re-booking a long line of inconvenienced
travellers. Suddenly an angry passenger pushed his way to the desk. He slapped
his ticket down on the counter and said, "I HAVE to be on this flight and it
HAS to be FIRST CLASS".
The attendant replied, "I'm sorry, sir. I'll be happy to try to help you, but
I've got to help these people first, and I'm sure we'll be able to work
something out."
The passenger was unimpressed. He asked loudly, so that the passengers behind
him could hear, "DO YOU HAVE ANY IDEA WHO I AM?"
Without hesitating, the attendant smiled and grabbed her public address
microphone: "May I have your attention please, may I have your attention
please," she began - her voice heard clearly throughout the terminal. "We have
a passenger here at Gate 14 WHO DOES NOT KNOW WHO HE IS. If anyone can help him
find his identity, please come to Gate 14."
With the folks behind him in line laughing hysterically, the man glared At the
Virgin attendant, gritted his teeth and said, "F... You!"
Without flinching, she smiled and said, "I'm sorry, sir, but you'll have to get
in line for that too."
Joel on Software: ". We also have one of those RSS thingamajiggies. If you don't know what that is, consider yourself lucky."