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
| abstract class Cloneable[T <: Cloneable[T]] { | |
| def clone(original: T): T | |
| } | |
| class TestChild(name: String) extends Cloneable[TestChild] { | |
| def clone(original: TestChild) = { | |
| new TestChild(original.name) | |
| } | |
| } |
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
| abstract class AbsIterator { | |
| type T | |
| def hasNext: Boolean | |
| def next: T | |
| } | |
| trait RichIterator extends AbsIterator { | |
| def foreach(f: T => Unit) { while (hasNext) f(next) } | |
| } |
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 Logger { | |
| def log(msg: String)(implicit logType: String) = { | |
| println(s"${logType}: ${msg}") | |
| } | |
| } | |
| object DefaultLogger extends Logger | |
| class SomeClass { | |
| implicit val logType = "SomeClass" |
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 BobLike { | |
| val name = "Bob" | |
| } | |
| trait PersonLike { | |
| var money: Double | |
| def isWealthy = money > 10000000 | |
| } |
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
| extension Array { | |
| mutating func appendReturn(item: Array.Element)-> Array.Element { | |
| self.append(item) | |
| return 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
| import Foundation | |
| enum Coin: Int, CustomStringConvertible { | |
| case Tails, Heads | |
| var description: String { | |
| if self == .Tails { | |
| return "T" | |
| } else { | |
| return "H" |
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 Main extends App { | |
| implicit val queue: dispatch.queue = "goodbyeQueue" | |
| def sayHello = () => {println("hello")} | |
| def sayGoodbye = () => {println("goodbye")} | |
| dispatch.async(sayHello)("helloQueue") | |
| dispatch async sayGoodbye | |
| } |
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
| enum Testing: String { | |
| case Thing = "thing" | |
| case Bob = {.Bob + "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 Test { | |
| struct Inside { | |
| } | |
| } | |
| let a = [Test.Inside]() |
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
| struct Bob { | |
| let lastName: String | |
| static var creth: Bob { | |
| return Bob(lastName: "Creth") | |
| } | |
| static func bobNamedFlumper() -> Bob { | |
| return Bob(lastName: "Flumper") | |
| } |