What causes the different behaviors between “var” and “let” when assign them a returned value of a function which throws an error

Declarations of var variables get hoisted – the variable name initialization gets hoisted to the top of the containing function (or, if no function, to the top of the outer block). So var withVar = (function() {throw ‘error!’})() is parsed by the interpreter as var withVar; withVar = (function() {throw ‘error!’})() The same is not … Read more

When to use a Var instead of a function?

Yes, a Var in Clojure is similar to a C pointer. This is poorly documented. Suppose you create a function fred as follows: (defn fred [x] (+ x 1)) There are actually 3 things here. Firstly, fred is a symbol. There is a difference between a symbol fred (no quotes) and the keyword :fred (marked … Read more

PHPDoc type hinting for array of objects?

In the PhpStorm IDE from JetBrains, you can use /** @var SomeObj[] */, e.g.: /** * @return SomeObj[] */ function getSomeObjects() {…} The phpdoc documentation recommends this method: specified containing a single type, the Type definition informs the reader of the type of each array element. Only one Type is then expected as element for … Read more