Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You’re not forced to use the "imperative verbosity" in the article. The following is shorter and more idiomatic.

    serializeType := model.SerializeNonArchivedOnly
    if showArchived {
        serializeType = model.SerializeAll
    }


How is this not imperative verbosity?

Not to mention you are mutating an already assigned variable. You run in to problems when you want to know the type of serializeType and you look at the first assignment but don't see that there is a second one.


> You run in to problems when you want to know the type of serializeType and you look at the first assignment but don't see that there is a second one.

Go is statically typed, so the type of serializeType doesn't change, only the value.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: