Skip to content

Instantly share code, notes, and snippets.

object Test {
def update[T](t: T) {
println(t)
}
}
scala> Test() = 1
1
package zoo;
class Animal {}
class Lion extends Animal {}
class Cage<T extends Animal> {
void add(T animal) { System.out.println("Adding animal..."); }
public static void main(String... args) {
package zoo
class Animal
class Lion extends Animal
class Cage[+T <: Animal] {
def add(animal: T) { println("Adding animal...") } // ERROR
}
trait Coffee {
def id: Long
def name: String
def brand: String
}
Query.from[Coffee]
.select(_.id)
.where(_.brand == "FairTrade")
scala> implicit case class Foo(foo: Int) extends AnyVal
defined class Foo
scala> Foo(1)
<console>:10: error: ambiguous reference to overloaded definition,
both method Foo of type (foo: Int)Foo
and object Foo of type Foo.type
match argument types (Int)
Foo(1)
^
scala> import java.nio.file.Paths
import java.nio.file.Paths
scala> val inputPaths = Paths.get(".")
inputPaths: java.nio.file.Path = .
scala> val inputPaths = Paths.get("test")
<console>:8: error: type mismatch;
found : String("test")
required: java.net.URI
java.io.IOException: log:null
R/W/S=1956/0/0 in:NA [rec/s] out:NA [rec/s]
minRecWrittenToEnableSkip_=9223372036854775807 LOGNAME=null
HOST=null
USER=mapred
HADOOP_USER=null
last Hadoop input: |null|
last tool output: |null|
Date: Sun Sep 02 06:08:56 CEST 2012
java.io.IOException: Broken pipe
//// scala/time/package.scala
package scala
package object time {
type Duration = javax.time.Duration
implicit def DurationToRichDuration(duration: Duration) = new RichDuration(duration)
type Instant = javax.time.Instant
implicit def InstantToRichInstant(instant: Instant) = new RichInstant(instant)
/** Doc */
// Comment
def foo ...
class throws[T <: Throwable](cause: String) extends scala.annotation.StaticAnnotation {
def this(clazz: Class[T]) = this("")
}