This file contains 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 Animal | |
trait Furry extends Animal | |
trait HasLegs extends Animal | |
class Cat extends Animal with Furry with HasLegs | |
class Dog extends Furry with HasLegs | |
class Dog with Furry with HasLegs // won't work |
This file contains 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 Animal | |
trait Furry extends Animal | |
trait HasLegs extends Animal |
This file contains 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 Rectangle(width: Int, height: Int) { | |
def getWidth: Int = width | |
def getHeight: Int = height | |
} | |
class Square(side: Int) extends Rectangle(side, side) { | |
def getSomething: Int = 1 | |
} | |
def area(rectangle: Rectangle): Int = { | |
rectangle.getHeight * rectangle.getWidth * rectangle.getSomething // it would't work! |
This file contains 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 Rectangle(width: Int, height: Int) { | |
def getWidth(): Int = width | |
def getHeight(): Int = height | |
} | |
class Square(side: Int) extends Rectangle(side, side) | |
def area(rectangle: Rectangle): Int = { | |
rectangle.getHeight() * rectangle.getWidth() | |
} |
This file contains 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 Rectangle(width: Int, height: Int) | |
class Square(side: Int) extends Rectangle(side, side) | |
val s = new Square(5) |
This file contains 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
<?php | |
/** | |
* (c) Artem Ostretsov <artem@ostretsov.ru> | |
* Created at 15.10.2014 12:31 | |
*/ | |
namespace SP\EventBundle\Validator\Constraints; | |
use Symfony\Component\Validator\Constraint; |
This file contains 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
<?php | |
/** | |
* (c) Artem Ostretsov <artem@ostretsov.ru> | |
* Created at 15.10.2014 12:32 | |
*/ | |
namespace SP\EventBundle\Validator\Constraints; | |
use SP\EventBundle\Entity\EventRequest; |
This file contains 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(l: Int) { | |
private val length = l | |
} | |
class AMinified (private val length: Int) // avoid code smell |
This file contains 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
def f1() = 1 | |
def f2 = 2 | |
f1() | |
f1 | |
// f2() // it doesn't work as expected! | |
f2 |
This file contains 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
def f1(x: Int, y: Int) = x + y | |
def f2(x: Int)(y: Int) = x + y | |
println(f1(1, 2)) | |
println(f2(1) { | |
val a = 5 | |
val b = 6 | |
a + b | |
}) |