Ben Chuanlong Du's Blog

It is never too late to learn.

Hands on Array in Golang

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

Comment

  1. Array in Golang is similar to Array in Rust in the sense that the length of an array is part of its type and must be determined at compile time.

  2. Array is a primitive (value) type in Golang. When assigned to another variable or passed as a parameter, it is copied! For this reason, array is not a good interface to use. Slice is prefer to array for function parameters.

Numpy Arrays in Python

Tips and Traps

  1. The Pythonic way of checking whether a collection (string, list, set, dict, etc.) coll is non-empty is to use if coll. However, do NOT use if arr to check whether a numpy array is non-empty or not. Instead, you shoule use arr.size >0 to check whether a numpy array is non-empty or not.

Misc Tips on Java

Tips and Traps

  1. Use == (instead of the method Object.equals) to compare objects is a common and tricky mistake for beginner.

  2. You cannot define an abstract static method. This is because "abstract" means that no functionality is implemented while "static" means that functionality exists even there is no object. The two conflict in concept.