Why there are two ways of declaring variables in Go, what’s the difference and which to use?

The Variable declarations make it clear that variables are declared. The var keyword is required, it is short and expresses what is done (at the file level everything excluding comments has to start with a keyword, e.g. package, import, const, type, var, func). Like any other block, variable declarations can be grouped like this: var …

Read more

javascript- Uncaught SyntaxError: Identifier * has already been declared

This is surprising as javascript var doesn’t respect block scope but functional scope… Sure, but you didn’t use var for the declaration of a in the block scope. You used a function declaration, which does respect block scopes (otherwise it would be completely invalid code, as in ES5 strict mode). It’s permissible in javascript to …

Read more

Lazy Var vs Let

This is the latest scripture from the Xcode 6.3 Beta / Swift 1.2 release notes: let constants have been generalized to no longer require immediate initialization. The new rule is that a let constant must be initialized before use (like a var), and that it may only be initialized: not reassigned or mutated after initialization. …

Read more

What is /var/www/html? [closed]

/var/www/html is just the default root folder of the web server. You can change that to be whatever folder you want by editing your apache.conf file (usually located in /etc/apache/conf) and changing the DocumentRoot attribute (see http://httpd.apache.org/docs/current/mod/core.html#documentroot for info on that) Many hosts don’t let you change these things yourself, so your mileage may vary. …

Read more