Edited, memorised or added to reading queue

on 06-Aug-2015 (Thu)

Do you want BuboFlash to help you learning these things? Click here to log in or create user.

Flashcard 149627434

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Why would List<ScheduledFuture<?>> be rejected by a method:
public static <T extends Comparable<T>> T max(List<T> list)
but accepted (as intended) by this:
public static <T extends Comparable<? super T>> T max(List<? extends T> list)
?
Answer
java.util.concurrent.ScheduledFuture does not implement Comparable<ScheduledFuture>. Instead, it is a subinterface of Delayed, which extends Comparable<Delayed>. In other words, a ScheduledFuture instance isn’t merely comparable to other ScheduledFuture instances; it’s comparable to any Delayed instance, so we have to say Comparable<? super T>. Delayed is super of ScheduledFuture. It seems that the second part, List<? extends T> as a producer does not make any difference.

basically:
ScheduledFuture extends Comparable<Delayed>
where Delayed is super of ScheduledFuture

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149636638

Tags
#scala
Question
When a function value containing a return statement is evaluated nonlocally, [...]
Answer
the computation is dropped and the result is returned by throwing a NonLocalReturnControl[A].

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

Parent (intermediate) annotation

Open it
When a function value containing a return statement is evaluated nonlocally, the computation is abandoned and the result is returned by throwing a NonLocalReturnControl[A].

Original toplevel document

tpolecat
it returns from the method it appears in. Another example: def foo: Int = { val sumR: List[Int] => Int = _.foldLeft(0)((n, m) => return n + m) sumR(List(1,2,3)) + sumR(List(4,5,6)) } scala> foo res4: Int = 1 Non-Local Return <span>When a function value containing a return statement is evaluated nonlocally, the computation is abandoned and the result is returned by throwing a NonLocalReturnControl[A]. This implementation detail escapes into the wild without much ceremony: def lazily(s: => String): String = try s catch { case t: Throwable => t.toString } def foo: String = laz







Flashcard 150902135

Tags
#2015 #book-2 #cfa #cfa-level-1 #economics #schweser
Question
The eventual outcome of Vickrey auction is much like that of [...] auction, where the winning bidder pays one increment of price more than the price offered by the bidder who values the item second-most highly.
Answer
an ascending price (English)

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

Parent (intermediate) annotation

Open it
The eventual outcome of Vickrey auction is much like that of an ascending price auction, where the winning bidder pays one increment of price more than the price offered by the bidder who values the item second-most highly.

Original toplevel document (pdf)

cannot see any pdfs