Bash script what is := for?

From Bash Reference Manual: ${parameter:=word} If parameter is unset or null, the expansion of word is assigned to parameter. The value of parameter is then substituted. Positional parameters and special parameters may not be assigned to in this way. Basically it will assign the value of word to parameter if and only if parameter is … Read more

var vs := in Go

In Go, top-level variable assignments must be prefixed with the var keyword. Omitting the var keyword is only allowed within blocks. package main var toplevel = “Hello world” // var keyword is required func F() { withinBlock := “Hello world” // var keyword is not required }

The forgotten assignment operator “=” and the commonplace “:=”

In PL/PgSQL parser, assignment operator is defined as assign_operator : ‘=’ | COLON_EQUALS ; This is a legacy feature, present in source code since 1998, when it was introduced – as we can see in the PostgreSQL Git repo. Starting from version 9.4 it is oficially documented. This idiosyncrasy – of having two operators for … Read more

What is the difference between := and = in Go?

= is assignment. more about assignment in Go: Assignments The subtle difference between = and := is when = used in variable declarations. General form of variable declaration in Go is: var name type = expression the above declaration creates a variable of a particular type, attaches a name to it, and sets its initial … Read more

When should I use the := operator in data.table?

Here is an example showing 10 minutes reduced to 1 second (from NEWS on homepage). It’s like subassigning to a data.frame but doesn’t copy the entire table each time. m = matrix(1,nrow=100000,ncol=100) DF = as.data.frame(m) DT = as.data.table(m) system.time(for (i in 1:1000) DF[i,1] <- i) user system elapsed 287.062 302.627 591.984 system.time(for (i in 1:1000) … Read more