make a virtualenv in a directory called vdir
with:
$ virtualenv vdir [-p pythonX.X]
start using the virtualenv in vdir
with:
$ source vdir/bin/activate
import scala.collection.mutable.ArrayDeque | |
object Co_and_Contra_Variance { | |
def main(args: Array[String]): Unit = { | |
theBasicIdea() // - What covariance and contravariance let you do, without discussing why or how | |
theCoreConceptIsBasedOnFunctions() // - How do we decide if function f1 can be substituted by f2? (aka f2 is subtype of f1) | |
bringItAllTogether() // - Now that we know why and how, let's see how it applies | |
} | |
def theBasicIdea(): Unit = { |
object ByName { | |
/** | |
* So-called 'by name' function parameters are basically automatically wrapped in thunks | |
* | |
* how 'by name' function are desugared: | |
* | |
* def f(x: => Int): Int = { x; x } | |
* f( { println("once"); 1 } ) | |
* | |
* desugars to |