5 ms·
Named parameters can be sort of gotten by passing a struct as the parameter, then you can do type fooParams struct { Name string Age int Address string }
by NateDad 13y ago
Named parameters can be sort of gotten by passing a struct as the parameter, then you can do
type fooParams struct {
Name string
Age int
Address string
}
foo( fooParams{ Name = "Bob", Age = 24 } )
Defaults are a lot harder to do in a way that doesn't just suck. You can make a DefaultFooParam that has all the defaults... but it's not pretty.
List comprehensions never seemed like a big deal to me. It's 3-4 lines for a loop, which is probably easier to read than the list comprehension anyway.
- baq 13y ago> List comprehensions never seemed like a big deal to me. It's 3-4 lines for a loop, which is probably easier to read than the list comprehension anyway. that's totally a nope. def qsort(L): if len(L) <= 1: return L return qsort([lt for lt in L[1:] if lt < L[0]]) + [L[0]] + qsort([ge for ge in L[1:] if ge >= L[0]])
- NateDad 13y agoI just saw this several days late, but have to comment.... is that really the example you're giving of a list comprehension that's easy to read? Because... yeah no. If I saw this in a code review, the first thing I'd say is "this code is illegible, please reformat to make it easier to read" This is classic "I'm trying too hard to make my code look clever rather than make it readable and easy to understand".