[Comment] Re: Bill Maher takes a beating

0
That's what I was going to write on my blog! Jesus H. Christ does that guy get on your last nerve, or what? Not that some of the talking heads on the right aren't just as annoying, but, at least they're on my side – they trust the president – they know the definition of the word enemy – and they love this country. Great Blog!

[BlogEntry] Iterating over a Hash in Ruby

0

Let's say you define a simple Hash.

irb(main):001:0> h1 = {"a"=>1,"b"=>2,"c"=>3}
=> {"a"=>1, "b"=>2, "c"=>3}

What do you think you'll get when you send an each message to it? I figured either a, b, c or 1, 2, 3. Surprise:

irb(main):003:0> h1.each{|a| puts a}
a
1
b
2
c
3
=> {"a"=>1, "b"=>2, "c"=>3}

It all comes out, keys and values interleaved.

Now, the trick becomes figuring out what to Google for to learn the syntax that gets you just the part of the hash you're after. Let me save you a little time. What you're after is each_value.

irb(main):008:0> h1.each_value {|a| puts a}
1
2
3
=> {"a"=>1, "b"=>2, "c"=>3}

You can also use each_key. Fairly intuitive, once you know it. Ah, there's the rub. 🙂

irb(main):009:0> h1.each_key {|a| puts a}
a
b
c
=> {"a"=>1, "b"=>2, "c"=>3}

[Comment] Re: Java the Hut

0
Anyone remember Lotusnotes (later renamed domino)? That was a platform alright. A giant one.

Some people, frustrated with Domino, started complaining how it looks more and more like 'a giant solution in search of a problem'.

Today, some of us are starting to feel that J2EE is another one of those 'giant solutions in search of a problem.' Yes, you may get paid big bucks for doing some J2EE work today, but back in the mid-late '90s, you could've done the same with Domino. Today? I honestly doubt it.

J2EE is slowly turning into the legacy platform. It is going the way om mainframes. That is to say, the way of dynosaurs.

The handwriting is clearly on the wall. Get out while there is still an opportunity.

[Comment] Re: Java the Hut

0
Actually, Rails is more the platform than Ruby.

Kinda interesting how I ended up here. Looking at that Simpleology stuff, ended up on Joyner's forum, read your "I'm crap at marketing" post, and now I'm reading about Ruby on Rails, which I've been using full-time for almost a year now. 🙂 Anything I say about it is going to be very subjective, I'm afraid 😉

Consider that you need to take risks to get the big prize. I started with Rails a year ago when it was a complete unknown. Now? I have work coming out of my ears because I'm one of the most experienced with it and the demand is higher than supply. It's not Java.. demand didn't grow slowly.. it's rocketing! A risk that paid off.

[BlogEntry] Exception handling in Ruby

0

I'm not sure why every language feels the need to use its own keywords. What would be the crime if all languages used throw, raise, and catch?

Anyway, if you want to examine the Exception object in Ruby, in the rescue line, just add => e as in

    rescue => e

Now, the local variable, e, contains the Exception object, which you can log:

    $mylog.debug("In Rescue block: " + e)