More Organs → More Human

Stupid things I've figured out so that you don't have to.


Site Feed

Sunday, November 27, 2005

LinkedHashSet

Did you know that you can add null to a LinkedHashSet, and have it take up space and appear in an Iterator? Neither did I, until just now.



00001: LinkedHashSet lhs = new LinkedHashSet();
00002:
00003: lhs.add(null);
00004:
00005: System.out.println(lhs.size()); // outputs 1



Something about this doesn't seem quite right to me, but I'm not sure what. I guess I'm used to null sort of being, well, null.

Also, Ruby's officially spoiled me. I've grown horribly used to its excellent "unless" syntax. For instance, to only add something to a collection if it's not null is one line in Ruby:



00001: someCollection.add(foo) unless foo.nil?



In Java, however, it's quite a process:



00001: if (foo != null) {
00002: someCollection.add(foo);
00003: }



It's only a few more lines, but it really messes with the flow of typing somehow. Maybe I'll hack together a quick IntelliJ macro or something...

Tuesday, November 15, 2005

Gah

OK, I really didn't want this blog to be one of those whiney political soapbox blogs. Any thoughts or opinions that I could lay down are already out there on the 'net already, written by others far more eloquent than I. But just this once, I'm feeling the need to vent.

I've got a real quick message for our government. Quick, quick, quick, and hopefully not too preachy. Here goes:

Hey, guys? Could we please stop torturing people now? Please? Oh, and also: please, please stop lying about the torture. Listening to our government try and mince words to justify torturing prisoners is ten thousand times more excruciating than it was to listen to Bill Clinton try and mince words to get out of having to admit to some extra-curricular nookie. I don't care what you call it- we are, indeed, torturing people. We know it. Other countries know it. The Iraqis sure as hell know it, and so does the rest of the Muslim world. All sorts of people know it, and the further we go down this path of pretend-self-righteousness, the harder it will be to undo the damage we've already done.

OK, got that off my chest. I could go on and on, but that's not really what my blog's for, and, like I said, others have that base covered far better than I ever could. Back to your regularly-scheduled programming.