This file contains hidden or 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 java.util.*; | |
public class DiamondOperators { | |
public static void main(String[] args) { | |
Collection<? extends Number> collection = null; | |
List<? super String> list = new ArrayList<>(collection); | |
} | |
} |
This file contains hidden or 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
val result = sqlManager.iterate(classOf[Book], Sql("SELECT BOOK_ID, BOOK_NAME, AUTHOR, PRICE FROM BOOK")){book => | |
sum = sum + book.price | |
sum | |
} |
This file contains hidden or 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
public class GJava { | |
public static void main(String[] args) { | |
GScala<String> s = new GScala<String>("FOO"); | |
System.out.println(s.value()); | |
} | |
} |
This file contains hidden or 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
trait Association { | |
type Item <: AbstractItem | |
trait AbstractItem { | |
def memberOf(): Group | |
} | |
type Group <: AbstractGroup | |
trait AbstractGroup { | |
def addItem(item: Item) | |
def removeItem(item: Item) | |
def items(): List[Item] |
This file contains hidden or 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
object ReturnFromAnonymousFunction { | |
def main(args: Array[String]) { | |
(1 to 10).foreach{i => | |
println(i) | |
if(i < 5) return | |
} | |
} | |
} |
This file contains hidden or 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
object GenTypeConstraints { | |
type ||[A, B] = Either[A, B] | |
implicit def any2Left[A, B](l: B): Either[B, A] = Left(l) | |
implicit def any2Right[A, B](r: B): Either[A, B] = Right(r) | |
def main(args: Array[String]) { | |
println(f(1)) | |
println(f("FOO")) | |
// compilation error println(f(1.0D)) | |
} | |
def f[T](v: T)(implicit ev: T => (String || Int)): String = { |
This file contains hidden or 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
--- SqlManager.scala.orig 2011-08-16 01:40:50.603000000 +0900 | |
+++ SqlManager.scala 2011-08-16 02:04:16.069118600 +0900 | |
@@ -8,10 +8,7 @@ | |
/** | |
* SqlManager wrapper for Scala. | |
*/ | |
-class SqlManager(sqlManager: jp.sf.amateras.mirage.SqlManagerImpl) { | |
- | |
- // TODO もう少しいい初期化の方法はないかなぁ | |
- BeanDescFactoryInitializer.initialize() |
This file contains hidden or 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
//Link testa and testz. | |
//To compile this file, testz.scala, testa.scala, and test.scala must be compiled. | |
//In this approach, we can select different implementation of test.A | |
object link extends test with testa with testz { | |
class A extends super[testa].A with super[testz].A | |
def main(args: Array[String]) { | |
val a = new A | |
println(a.aaa()) | |
println(a.aaa2()) | |
println(a.zzz()) |
This file contains hidden or 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
Welcome to Scala version 2.9.0.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> trait scope { | |
| class A extends AnyRef with Z { | |
| def aaa() = zzz2() | |
| def aaa2() = 100 | |
| } |
This file contains hidden or 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
trait VisitorsBase {self => | |
trait Node { | |
def accept(v: V) | |
} | |
case class Add(l: Node, r: Node) extends Node { | |
def accept(v: V) { | |
v.visit(this) | |
} | |
} | |
case class Sub(l: Node, r: Node) extends Node { |