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 StringLiteralType { | |
def isAType(arg: String): Unit = arg match { | |
case _ : "a" => println("This is `a` type") | |
case _ => println("not `a`") | |
} | |
def a1 = isAType("a") | |
def a2 = isAType(new String("a")) | |
def a3 = new String("a").isInstanceOf["a"] |
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 StringLiteralType { | |
def isAType(arg: String): Unit = arg match { | |
case _ : "a" => println("This is `a` type") | |
case _ => println("not `a`") | |
} | |
def a1 = isAType("a") | |
def a2 = isAType(new String("a")) | |
def a3 = new String("a").isInstanceOf["a"] |
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 LargeStringInterpolation { | |
public int a(); | |
Code: | |
0: aload_0 | |
1: getfield #15 // Field a:I | |
4: ireturn | |
public java.lang.String s33(); | |
Code: | |
0: aload_0 |
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 LargeStringInterpolation extends App { | |
val a = 1 | |
val s32 = s"$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a" | |
val s33 = s"$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a" | |
val s34 = s"$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a" | |
val s35 = s"$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a" | |
println("Hello") | |
} |
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
class A { | |
def foo(x: Int): Int = 1 | |
} |
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
final object ExplicitlyFinalObject { | |
val NonFinalVal = 1 | |
final val FinalVal = 2 | |
} | |
object ImplicitlyFinalObject { | |
val NonFinalVal = 1 | |
final val FinalVal = 2 | |
} |
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
class M a where | |
(+) :: a -> a -> a | |
add x y = x + y | |
main = do print "Hello" |
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
sealed abstract class Nest | |
case class NLeaf(code: Char) extends Nest | |
case class NList(elements: List[Nest]) extends Nest | |
def group(tokens: List[Char]): List[Nest] = { | |
def process(nest: List[Nest], acc: List[Nest], remain: List[Char]): (List[Nest], List[Nest], List[Char]) = { | |
remain match { | |
case Nil => | |
(nest, Nil, Nil) | |
case ('(')::rest => |
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 Hello extends App { | |
def main(args: Array[String]): Unit = { | |
println("Hello") | |
} | |
} |
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
sealed abstract class T1 | |
object T1 { | |
case class A(x: Int) extends T1 | |
case class B(x: Double) extends T1 | |
case class C(x: String) extends T1 | |
implicit val ordA: Ordering[A] = (a, b) => a.x compare b.x | |
implicit val ordB: Ordering[B] = (a, b) => a.x compare b.x | |
implicit val ordC: Ordering[C] = (a, b) => a.x compare b.x | |
} |