Ben Chuanlong Du's Blog

It is never too late to learn.

Const and Static Variables in C++

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Const Variables

but you can initialize a static constexpr variable inside the defintion of a class.

  1. constexpr means that the corresponding value can be dertermined at compile time.

Static Variables

  1. You …

For Loops in C++

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

There are 3 for loops in C++, the usual for loop, the range-based for loop (introduced in C++11) and the std::for_each for loop.

  1. Both the range-based for loop and …

Function Programming in Python

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

  1. The built-in function map applies a function to each element of an iterable. map is not useful mostly of time as Python has list comprehension, etc. map support iterating multiple iterables …

Java Features

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

  1. String in Switch

Java 7 allows use of strings in switch instead of just integers, which make things much more convenient (see the following example).

public void foo(Foo t) {
    String …