4 ms·
So how _do_ you handle nil without those things? You've said you try to just avoid it, but many functions return nil and there's no easy way around it (e.g. try
by degrews 8y ago
So how _do_ you handle nil without those things? You've said you try to just avoid it, but many functions return nil and there's no easy way around it (e.g. trying to get the max value of an empty list)
- qop 8y agoRepresent the problem programatically. If there's some reason data is missing, use a symbol :idk, :not-provided, etc. Programs DO things, use what you're doing to describe your program, whenever possible. In a better world, max([]) # -> None(T) But sometimes we have to get creative...
- hellofunk 8y agoFunctions only return nil when nil is a valid value in your logic.