Out of curiosity, what would be the idiomatic way to assign a variable if it's nil in go?
I'm looking for something similar to ruby's foo ||= bar
Is there a shorter version of this?
if foo == nil{
foo = bar
}
Out of curiosity, what would be the idiomatic way to assign a variable if it's nil in go?
I'm looking for something similar to ruby's foo ||= bar
Is there a shorter version of this?
if foo == nil{
foo = bar
}
Your version is already the simplest, shortest and idiomatic way to do it.