Comemnt¶
- The methods
BufferedRead.readLineandBufferedRead.linesare very helpful for reading text Files.
public String BufferedRead.readLine¶
Reads a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed.
public Stream\<String> BufferedRead.lines¶
Returns a Stream, the elements of which are lines read from this BufferedReader. The Stream is lazily populated, i.e., read only occurs during the terminal stream operation. The reader must not be operated on during the execution of the terminal stream operation. Otherwise, the result of the terminal stream operation is undefined.
Builtin Objects Python
Python has built-in functions and object that users can use directly (no need to import).
However,
if you import another module which hide a built-in function or object,
you cannot use it anymore.
For example,
sum is a built-in function in Python which can be used directly.
However,
if you use PySpark import SQL functions (from pyspark.sql.functions import *
HashMap in Scala
Comment¶
HashTable is a trait without a factory method and thus cannot be instantiated. HashMap and HashSet are subclasses that you should use.
https://stackoverflow.com/questions/3648870/scala-using-hashmap-with-a-default-value
The Source Class in Scala IO
Assert in Java
- Avoid using
assertin Java production code as assertion is not turned on by default. Throw exception instead (since assert is just a syntax sugar of throwing exceptions).
The most important thing to remember about assertions is that they can be disabled, so never assume they'll be executed.
Therefore keep the followings things in mind when using assertions:
MutableList in Kotlin
MutableList vs ArrayList¶
MutableList is ArrayList in Kotlin currently.
Create an Empty MutableList¶
Below is the most idiomatical way to create an empty mutable list in Kotlin.