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
| case class ElectricCar(b: Battery) { def batteryLevel = b.filledPercentage } | |
| case class GasolineCar(g: GasTank) { def gasLevel = g.filledPercentage } | |
| case class Battery(filledPercentage: Int) { def fill: Battery = Battery(100) } | |
| case class GasTank(filledPercentage: Int) { def fill: GasTank = GasTank(100) } | |
| trait Fills[C] { | |
| def fill(car: C): C |
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 | |
| class A2 extends A | |
| class B | |
| trait M[X] | |
| // | |
| // Upper Type Bound | |
| // | |
| def upperTypeBound[AA <: A](x: AA): A = x |
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
| (ns test.dialect | |
| (:require [clojure.contrib.string :as st])) | |
| (defn pig-latinize [word] | |
| (let [fs (str (first word))] | |
| (str | |
| (if (re-seq #"(?i)[aeiou]" fs) | |
| word | |
| (str (subs word 1) fs)) | |
| "ay"))) |
NewerOlder