Edited, memorised or added to reading list

on 14-Dec-2014 (Sun)

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

#odersky-programming-in-scala-2ed #scala
Any standalone object with a main method of the proper signature can be used as the entry point into an application.

statusnot read reprioritisations
last reprioritisation on reading queue position [%]
started reading on finished reading on

pdf

cannot see any pdfs




#odersky-programming-in-scala-2ed #scala
Scala implicitly imports members of packages java.lang and scala, as well as the members of a singleton object named Predef, into every Scala source file.

statusnot read reprioritisations
last reprioritisation on reading queue position [%]
started reading on finished reading on

pdf

cannot see any pdfs




Flashcard 149629968

Tags
#odersky-programming-in-scala-2ed #scala
Question
How to express s.indexOf(’o’, 5) in operator notation?
Answer
s indexOf ('o', 5)


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 149630004

Tags
#odersky-programming-in-scala-2ed #scala
Question
Scala will transform the expression -2.0 into [...]
Answer
the method invocation (2.0).unary_-


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 149630011

Tags
#odersky-programming-in-scala-2ed #scala
Question
if you define a method unary_* and then try to call it on object in prefix notation *p, how will Scala parse it and why?
Answer
*.p because * is not one of the four names allowed for prefix methods


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 149630031

Tags
#odersky-programming-in-scala-2ed #scala
Question
Postfix operators are methods that [what's their signature and how are they invoked?].
Answer
take no arguments, when they are invoked without a dot and parentheses


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 149630046

Tags
#odersky-programming-in-scala-2ed #scala
Question
How does scala decide on precedence when methods are used in operator notation, like 2 + 2 * 7 ? What is Scala's default rule here?
Answer
Scala decides precedence based on the first character of the methods used in operator notation (this rule has exceptions). If the method name starts with a *, for example, it will have a higher precedence than a method that starts with a +.


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







#odersky-programming-in-scala-2ed #scala
In Java, classes have constructors, which can take parameters, whereas in Scala, classes can take parameters directly.

statusnot read reprioritisations
last reprioritisation on reading queue position [%]
started reading on finished reading on

pdf

cannot see any pdfs




Flashcard 149630206

Tags
#odersky-programming-in-scala-2ed #scala
Question
Why won't this compile?

class Rational(n: Int, d: Int) { // This won’t compile
  require(d != 0)
  override def toString = n +"/"+ d
  def add(that: Rational): Rational =
  new Rational(n * that.d + that.n * d, d * that.d)
}
Answer
Because n and d can only be accessed in methods for this object - they seem to be captured like in closure for toString. They are not fields / members though


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 149630230

Tags
#odersky-programming-in-scala-2ed #scala
Question
In Scala, constructors other than the primary constructor are called
Answer
auxiliary constructors


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







#odersky-programming-in-scala-2ed #scala
Identifiers in user programs should not contain ‘$’ characters, even though it will compile; if they do this might lead to name clashes with identifiers generated by the Scala compiler.

statusnot read reprioritisations
last reprioritisation on reading queue position [%]
started reading on finished reading on

pdf

cannot see any pdfs




#odersky-programming-in-scala-2ed #scala
the identifier :-> would be represented internally as $colon$minus$greater

statusnot read reprioritisations
last reprioritisation on reading queue position [%]
started reading on finished reading on

pdf

cannot see any pdfs




Flashcard 149630349

Tags
#odersky-programming-in-scala-2ed #scala
Question
How to call Thread.yield() in Scala, where yield is a reserved word?
Answer
Thread.`yield`()
string enclosed in backticks becomes an identifier, no matter how arbitrary it is.


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







#odersky-programming-in-scala-2ed #scala
The only control structures in Scala are if, while, for, try, match, and function calls

statusnot read reprioritisations
last reprioritisation on reading queue position [%]
started reading on finished reading on

pdf

cannot see any pdfs




Flashcard 149630539

Tags
#odersky-programming-in-scala-2ed #scala
Question
How to write Unit as a literal?
Answer
()


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 149630550

Tags
#odersky-programming-in-scala-2ed #scala
Question
Why doesn't it work?

var line = ""
while ((line = readLine()) != "") // This doesn’t work!
  println("Read: "+ line)

Answer
the result of assignment expression is always Unit, so the above check Unit != "" is always true


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 149630657

Tags
#odersky-programming-in-scala-2ed #scala
Question
How to change it to exclude upper bound 4?

for (i <- 1 to 4)
  println("Iteration "+ i)

Answer
Use until method instead of to method:

for (i <- 1 until 4)
  println("Iteration "+ i)


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 149630676

Tags
#odersky-programming-in-scala-2ed #scala
Question
How to move the condition to the generator in the loop?

for (file <- filesHere)
  if (file.getName.endsWith(".scala"))
    println(file)

Answer

for (file <- filesHere if file.getName.endsWith(".scala"))
  println(file)


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 149630687

Tags
#odersky-programming-in-scala-2ed #scala
Question
What happens if you put multiple <- clauses in for?
Answer
You will get nested loops.


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 149630698

Tags
#odersky-programming-in-scala-2ed #scala
Question
How can you reduce number of semicolons in for loop?
Answer
Use curly braces instead of parentheses - Scala compiler will not infer semicolons in parentheses.


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 149630709

Tags
#odersky-programming-in-scala-2ed #scala
Question
How to introduce a val like variable mid-stream into for clauses?
Answer
Simply x=<whatever>, like val x=<whatever> elsewhere in the code, but without val keyword.


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 149630720

Tags
#odersky-programming-in-scala-2ed #scala
Question
What form of for produces a new collection?
Answer
for clauses yield body

Keyword yield makes body compute elements of the new collection.


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







#odersky-programming-in-scala-2ed #scala
One difference from Java that you’ll quickly notice in Scala is that unlike Java, Scala does not require you to catch checked exceptions, or declare them in a throws clause.

statusnot read reprioritisations
last reprioritisation on reading queue position [%]
started reading on finished reading on

pdf

cannot see any pdfs




Flashcard 149630747

Tags
#odersky-programming-in-scala-2ed #scala
Question
What will calling f() return?

def f(): Int = try { return 1 } finally { return 2 }

Answer
2


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 149630762

Tags
#odersky-programming-in-scala-2ed #scala
Question
What will calling g() return?
def g(): Int = try { 1 } finally { 2 }
Answer
1


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







MVA asset swap
#asset-swap #finance #gale-using-and-tradning-asset-swaps
MVA asset swap; trade: Bond bought for dirty price, plus a swap.

statusnot read reprioritisations
last reprioritisation on reading queue position [%]
started reading on finished reading on

pdf

cannot see any pdfs




Par/par asset swap
#asset-swap #finance #gale-using-and-tradning-asset-swaps
in par/par asset swap, swap notional is par (of the bond).

statusnot read reprioritisations
last reprioritisation on reading queue position [%]
started reading on finished reading on

pdf

cannot see any pdfs




Flashcard 149652854

Tags
#asset-swap #finance #gale-using-and-tradning-asset-swaps
Question
MVA asset swap: Swap notional is [what value and when is the value date of this value]?
Answer
bond dirty price at settlement.


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
Swap notional is bond dirty price at settlement.

Original toplevel document (pdf)

cannot see any pdfs







Flashcard 149652869

Tags
#asset-swap #finance #gale-using-and-tradning-asset-swaps
Question
in par/par asset swap, swap notional is [value?].
Answer
par (of the bond)


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
in par/par asset swap, swap notional is par (of the bond).

Original toplevel document (pdf)

cannot see any pdfs







Flashcard 149652892

Tags
#asset-swap #finance #gale-using-and-tradning-asset-swaps
Question
MVA asset swap; trade: Bond bought for [...], plus a swap.
Answer
dirty price


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
MVA asset swap; trade: Bond bought for dirty price, plus a swap.

Original toplevel document (pdf)

cannot see any pdfs