I hereby claim:
- I am arkadius on github.
- I am arkadius (https://keybase.io/arkadius) on keybase.
- I have a public key whose fingerprint is F2F2 22AD E13A EAC9 6349 9E22 C406 0852 104F 9B5A
To claim this, I am signing this object:
def casted(implicit classTag: ClassTag[T]): T = value match { | |
case t: T => t | |
case _ => throw new ClassCastException(s"Cannot cast $value to expected type: $classTag") | |
} |
object CastingTest extends App { | |
val boxWithListOfInts: CastingBox[List[Int]] = new CastingBox[List[Int]] { | |
val value = List("123") | |
} | |
println(s"value: ${boxWithListOfInts.casted}") | |
} |
trait CastingBox[T] { | |
val value: Any | |
def casted(implicit typeable: Typeable[T]): T = typeable.cast(value) match { | |
case Some(t) => t | |
case None => throw new ClassCastException(s"Cannot cast $value to expected type") | |
} | |
} |
class ProjectStateBinder | |
extends SimpleNgModelBinder("projectState", ProjectState(Nil)) | |
with BindingToClient | |
with CometListener { | |
override protected def registerWith = ApplicationContext().projectActor | |
override def lowPriority: PartialFunction[Any, Unit] = resendState orElse super.lowPriority | |
private def resendState: PartialFunction[Any, Unit] = { |
class ProjectStateBinder | |
extends SimpleNgModelBinder("projectState", ProjectState(Nil)) | |
with BindingToClient | |
with CometListener { | |
override protected def registerWith = ApplicationContext().projectActor | |
override def lowPriority: PartialFunction[Any, Unit] = resendState orElse super.lowPriority | |
private def resendState: PartialFunction[Any, Unit] = { |
object MicroBurnServices { | |
def render = renderIfNotAlreadyDefined( | |
angular.module("MicroBurnServices") | |
.factory("historySvc", jsObjFactory() | |
.future("getHistory", (sprintId: String) => | |
ApplicationContext().columnsHistoryProvider.columnsHistory(sprintId) | |
) | |
) | |
) | |
} |
app.controller("ProjectCtrl", ['$scope', 'historySvc', function ($scope, historySvc) { | |
(...) | |
var refreshChart = function () { | |
historySvc.getHistory($scope.selectedSprint.id).then(function (history) { | |
$scope.history = history; | |
}); | |
}; | |
(...) |
it should "do round-trip" in { | |
forAll(initialBoardAndChangesGenerator) { | |
case InitialBoardAndChanges(initialBoard, changes) => | |
lazy val boardAndEventsStream: Stream[(BoardState, Seq[TaskEvent])] = | |
(initialBoard, Nil) #:: | |
(boardAndEventsStream zip changes).map { | |
case ((prevBoard, events), changedBoard) => | |
val newAddedEvents = prevBoard.diff(changedBoard) | |
(changedBoard, newAddedEvents) | |
} |
I hereby claim:
To claim this, I am signing this object:
class A() | |
class B(val a: A) | |
class C(val b: B) | |
implicit def aToB(a: A) = new B(a) | |
implicit def sthConvertibleToBToC[T <% B](t: T): C = new C(t) | |
def doSthWithC[T <% C](t: T) = t.b | |
doSthWithC(new A) |