October 20, 2006

I've solved a few more Project Euler problems and read Ringworld.

A friend at school showed me operator overloading in C++. It's so cool because it lets you use arithmetic operators for whatever you want to, not restricted to arithmetic expressions. What does it mean to multiply a string by an integer, for instance? You could say, "concatenate this string n times with itself" so that "abc" * 3 results in "abcabcabc". Or it could mean, "produce the next three characters in the sequence and concatenate it", resulting in "abcdef". This might be illogical, but the point is that the behavior is entirely up to you. A more realistic example would be that of adding items to an inventory in an RPG (incidentally the example I was shown). Instead of doing something like Inventory.add(sword, shield, arrows) you could go Inventory += sword + shield + arrows. It would be so neat if Java supported operator overloading.

Java does support method and constructor overloading, which make things more powerful. It also has explicit constructor invocation, which is totally awesome.

I'm a web comics junkie, I know! Now, before you start scheming that intervention, check out Simulated Comic Product, Soup, and The Pretentious History of Everything, which are now linked to. I've also linked to Jim Wisniewski, who promptly became a Wilburer. (The first one in a long time. Who's next?)

"We don't like it when the city pigeons break wings. When the pigeons break wings, then we can't get down."

<< | Previous entry (October 16, 2006) | Next entry (October 24, 2006) | >>
Back to Archive