Normally the FooBar is full of other fields, necessitating the single field
patch.

On Sat, Aug 18, 2018, 1:17 PM Tim Peoples <t...@timpeoples.com> wrote:

> Regarding your issues with the following...
>
>
>> I've lost count of the times I've had to change:
>>
>> return FooBar{
>>     Field: blah,
>> }
>>
>> To:
>>
>> var foo FooBar
>> if someCond {
>>     foo.Field = blah
>> } else {
>>     foo.Field = bar
>> }
>> return foo
>>
>
>  ...I hardly consider that to be idiomatic Go.  A more go-like approach
> would be to follow the guideline to "return early" and write it more like
> this:
>
>  if someCond {
>   return FooBar{Field: blah}
> }
>
> return FooBar{Field: bar}
>
>
> ...which (IMHO) is markedly more readable than a ternary expression.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/golang-nuts/MrpkS4epn_E/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to