3 ms·
Speaking of the .Get method, wouldn't returning an error alongside the value instead of just the default object be more idiomatic?
by ryanlschneider 12y ago
Speaking of the .Get method, wouldn't returning an error alongside the value instead of just the default object be more idiomatic?
- libria 12y agoIt looks like .Get uses the null pattern (ie, returns a Jason struct with data = `nil` if nothing is found). Your way is more idiomatic, but it looks like his point with this library is to access the data conveniently in exchange for type-safety. `exists()` can verify something was found if needed.
- courtf 12y agoI think it would be nice to return a bool, rather than an error. It really is just a binary condition and this pattern fits nicely with accessing values in maps. That said, I haven't really found a need for a .Get method in my own code, and will probably just stick with encoding/json for the time being.