Skip to content

Instantly share code, notes, and snippets.

View andrewharmellaw's full-sized avatar

Andrew Harmel-Law andrewharmellaw

View GitHub Profile
@andrewharmellaw
andrewharmellaw / koans.bat
Created May 17, 2013 19:31
Working koans.bat for Windows 7
set SCRIPT_DIR=%~dp0
java -Dfile.encoding=UTF8 -Dsbt.boot.directory=.\sbtboot -Dsbt.ivy.home=.\ivyrepo -Xmx512M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m -jar "sbt-launch.jar"
@andrewharmellaw
andrewharmellaw / AboutClasses.scala
Last active December 17, 2015 11:19
Scala class with (mutable) var parameter
class ClassWithVarParameter(var description: String)
// Which is equivalent to the following in Java:
//
// public class ClassWithVarParameter() {
//
// private String description;
//
// public ClassWithVarParameter(String description) {
// this.description = description;
@andrewharmellaw
andrewharmellaw / AboutClasses.scala
Created May 17, 2013 20:14
Scala class with (immutable) val parameter
class ClassWithValParameter(val name: String)
// Which is equivalent to the following in Java:
//
// public class ClassWithValParameter() {
//
// private String description;
//
// public ClassWithVarParameter(String description) {
// this.description = description;
@andrewharmellaw
andrewharmellaw / AboutClasses.scala
Created May 17, 2013 20:17
Scala class with private (and immutable) parameter
val aClass = new ClassWithPrivateFields("name")
// NOTE: aClass.name is not accessible
// Which is equivalent to the following in Java:
//
// public class ClassWithValParameter() {
//
// private String description;
//
// public ClassWithVarParameter(String description) {
@andrewharmellaw
andrewharmellaw / AboutRanges.scala
Created May 20, 2013 18:45
Scala Ranges (basic)
val someNumbers = Range(0, 10) // gives me a scala.collection.immmutable.Range object which contains every Int from 0 to 9
@andrewharmellaw
andrewharmellaw / AboutRanges.scala
Created May 20, 2013 18:46
Scala Ranges (with intervals)
val someNumbers = Range(2, 10, 3) // gives me a scala.collection.immmutable.Range object which contains the Ints 2, 5, and 8
@andrewharmellaw
andrewharmellaw / Ranges.rb
Created May 20, 2013 18:46
Ruby Ranges (inclusive) - far more legible
someRubyNumbers = (1..5) // gives me a Ruby Range object which contains the Ints 1, 2, 3, 4 and 5
@andrewharmellaw
andrewharmellaw / Ranges.rb
Created May 20, 2013 19:12
Ruby Ranges (exclusive) - Spot the Difference
someRubyNumbers = (1…5) // gives me a Ruby Range object which contains the Ints 1, 2, 3, and 4
@andrewharmellaw
andrewharmellaw / AboutRanges.scala
Created May 20, 2013 19:14
Scala Ranges (Inclusive) - much better
val someNumbers = Range(0, 10).inclusive // gives me a scala.collection.immmutable.Range object which contains every Int from 0 to 10
val tuple = ("apple", "dog")
val fruit = tuple._1
val animal = tuple._2
fruit should be("apple")
animal should be("dog")