Posts
Erik's Ponderings
Cancel

Getting to know CanBuildFrom (without a PhD)

Recently I needed to write a pretty simple function: given a sequence of (name, value) pairs, return a sequence of (name, some collection of all the values having that name) pairs. Here is a simple...

More iterators goodness

Following-up on the previous post about iterators, say we have a clean Scala API with Option instead: class Foo { def parent: Option[Foo] = … } def findBar(foo: Foo) = Option[Bar] = … It turns ...

Scala iterators and Iterator.iterate

There is a common programming pattern where you navigate a hierarchy in order to find an element satisfying a certain condition. I have written code like this in Java probably a million times: cla...

Scala tip: getOrElseUpdate

I found myself recently looking at the following code which I wrote when I was getting started with Scala: def getModelState(modelPrefixedId: String) = modelStates.get(modelPrefixedId) match { ...

Scala tip: import renames

In Java, you often write things like this, which are rather verbose: URLEncoder.encode(...) URLDecoder.decode(...) Since Java 1.5 you can use static imports, but then you are stuck with the orig...

Scala partial functions (without a PhD)

If you have done some Scala for a while, you know about pattern matching and match/case. Things like: value match { case Some(value) => … case None => … } But there is another use of t...

Continuations in Scala (without a PhD)

With @avernet we have been thinking lately about continuations, for a few reasons: Continuations pop up on the web as a concept that could help with event-based programming Scala has a contin...

48 hours of Nexus One

I just used a Nexus One for 48 hours (thanks Pierre). Here are a few quick notes/thoughts from the perspective of an iPhone 3G user.Getting started <ul><li>Take the SIM card out of the...

2009: Products I Can’t Live Without

Mike Arrington has just posted his 2009 list of products he can’t live without. After my own 2008 list, here is my update for 2009 as I think it’s fun to observe how our computing environment evolv...

Upgrading Your 17" MacBook Pro Hard Drive

A few days ago I upgraded my MacBook Pro’s hard drive after realizing 320 GB drives sell for USD 110 - which made constantly worrying about disk space ridiculous. This also should extend my old MBP...