This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Pojo { | |
def doStuff(): Unit = println("rocket launched!") | |
} | |
object Example { | |
import NullDrivenDevelopment._ | |
def none: Pojo = null | |
def pojo: Pojo = new Pojo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Object1(field: String) | |
case class Object2(fields: List[String]) | |
trait CanBeMasked[T] { | |
def mask(o: T, f: String ⇒ String): T | |
} | |
object CanBeMasked { | |
implicit object O1 extends CanBeMasked[Object1] { | |
def mask(o: Object1, f: String ⇒ String) = o.copy(field = f(o.field)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> val fs = Field("string") | |
fs: Field[String] = Field(string) | |
scala> val fi = Field(1) | |
fi: Field[Int] = Field(1) | |
scala> val O = Update[Object] | |
O: Update[Object] = sparken.Update$$anon$1@4b41956d | |
// Runtime check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def f[T]: Unit = macro f_impl[T] | |
def f_impl[T: c.WeakTypeTag](c: Context): c.Expr[Unit] = { | |
import c.universe._ | |
def isConcreteTypeSymbol(sym: Symbol) = | |
sym.isType && !sym.asType.isAbstractType | |
def isConcreteType(tpe: Type): Boolean = tpe match { | |
case NoPrefix => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jsglr-layout [scala-ast]± scala -cp org.spoofax.terms_1.0.0.201105211714.jar:bin/ | |
Welcome to Scala version 2.10.0-20121205-235900-18481cef9b (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_17). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> val tableMgr = new org.spoofax.jsglr_layout.io.ParseTableManager() | |
tableMgr: org.spoofax.jsglr_layout.io.ParseTableManager = org.spoofax.jsglr_layout.io.ParseTableManager@1b3821a6 | |
scala> import java.io.File | |
import java.io.File |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//import scala.reflect.runtime.universe._ | |
import scala.reflect.runtime.{ currentMirror => m } | |
import scala.tools.reflect.ToolBox | |
import scala.tools.reflect.Eval | |
object Test extends App { | |
val tb = m.mkToolBox(options = "-Xprint:typer -Yshow-trees -Ydebug -Ytyper-debug") | |
class O { class I } | |
class A extends O { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package hr.the4e6; | |
import java.io.BufferedReader; | |
import java.io.FileNotFoundException; | |
import java.io.FileReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.net.MalformedURLException; | |
import java.net.URL; | |
import java.util.Arrays; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* to run from console: | |
* $scala DuplicatesFinder.scala /path/to/android/project | |
*/ | |
import java.io.File | |
import scala.xml._ | |
val folder = args(0) | |
val project = new File(folder) |
NewerOlder