Archive: 2017/10

0

Right associativity in Scala

We define two methods here, ++ and ++: 1234567891011class Foo { def ++(n: Int): Unit = println(n + 1) def ++:(n: Int): Unit = println(n + 1)}object ValFunctionTest { def main(args: A

0

Cast away on the moon

I watched a movie these days, it’s called Cast Away on the Moon(or 金氏漂流记 , 김씨 표류기). A man was saddled with debts of more than $20,000, and he couldn’t afford to pay it off. One day he jumped off a bri

0

Some Linux Commands

:-Take ${val1:-val2} for example, if val1 is unset or null, return val2, otherwise return val1. Example: 123456#!/bin/bashdefault="default"preset="preset"value="This is ${preset:-"$default"}

0

newInstance in Java

IntroductionnewInstance is used to instantiate an instance of a class dynamically. Here is an example written in Scala. 1234567891011class Printer() { def print(): Unit = { println(s"pri

0

When and how to use InheritableThreadLocal

Today I was reading Spark’s source code, and found InheritableThreadLocal in it. Little information could be found online about this class, so I decided to write a blog to illustrate how to use it, ba