News for hackers. Stuff that matters.
Re:Option and null in dynamic languages by NateDad on Tuesday December 09, 2014 @04:16PM (#8725812)
Not sure what you mean by needing a dummy value if your function only returns success/failure. That's what a boring old error return is for.

    func foo() error
Re:Option and null in dynamic languages by stormbrew on Tuesday December 09, 2014 @04:42PM (#8725991)
Yes, but unlike having a second result this particular error check need not be touched. To make it so the caller has to check it, I'd have to return a dummy normal return.
Re:Option and null in dynamic languages by NateDad on Wednesday December 10, 2014 @03:24PM (#8731451)
You can always call a function and not assign the return calls to anything.

If you have

func foo() (string, error)

You can still call it thusly:

foo()

However there are tools to check for unchecked errors like this one: https://github.com/kisielk/errcheck