Friday, 17 May 2013

The Scala Koans

While I’m waiting for the Kindle version of Atomic Scala to be released, I’m going to work my way slowly through the Scala Koans.  I got up and running really qiuckly, but the instructions at http://www.scalakoans.org/installation are a little out of date.  Here’s what worked for me (on Windows 7, with IntelliJ Idea 12.1.3):

  1. Download the Koans
  2. Unzip them somewhere
  3. Edit koans.bat so it looks like this:
  4. Run koans.bat (if you’re behind a firewall, you’ll need to set your proxy) This will download SBT, the Scala Simple Build Tool and start it. You’ll be left at the SBT prompt: “>”
  5. Compile the tests: “> test:compile”
  6. Start the tests running constantly: “> ~test-only org.functionalkoans.forscala.Koans” You will see your first task: “Please meditate on Koan …” This is your cue to start fixing the koans, and learning Scala and ScalaTest
  7. Start up IntelliJ IDEA
  8. Import a project – create it from existing sources. To do this just point IDEA at the unzipped archive. It should guess everything.  Make sure you use JDK 1.6 as 1.7 isn;t currently totally supported
  9. Find the scala test you’re being prompted to fix (it’ll most likely be dmarsh-scalakoansexercises-8d7da93dd5f2\src\test\scala\org\functionalkoans\forscala\AboutAsserts.scala)
  10. Fix the first broken test and switch back to your CMD window where SBT is running
  11. You’ll see it announce “Compiling 1 Scala source to …” and if you’ve fixed the test you’ll get a new prompt to meditate on the next one.
  12. Rinse. Repeat.

2 comments:

  1. Thanks for your post. This whole time I thought I was doing something wrong. I'm glad there was a solution.

    ReplyDelete
    Replies
    1. NP. Glad it helped. I really like the Koans. They need a few tweaks though (IMHO). I need to get round to submitting them...

      Delete