4 ms·
I think its less about a sign function than about showing how optional (i.e. nullable) values work. Most languages have them, and making that possibility expli
by CREwert 7y ago
I think its less about a sign function than about showing how optional (i.e. nullable) values work. Most languages have them, and making that possibility explicit is recent best practice.
- Someone 7y agoAs fjfaase said “The first is that you should try to include realistic examples in your documentation and promote good coding styles.” That ‘sign’ example could be somewhat improved by having it return an optional int instead (returning null on null inputs), or by having it take a double and return an optional int (returning null for not-a-numbers), but I think it isn’t that hard to come up with a more realistic short example.