3 ms·
Couldn't a "possibly null" member access operator help here? E.g.: var key = user?.them?.public_keys?.primary?.bundle; where object?.property is equi
by AshleysBrain 12y ago
Couldn't a "possibly null" member access operator help here? E.g.:
var key = user?.them?.public_keys?.primary?.bundle;
where
object?.property
is equivalent to
object ? object.property : null
- emidln 12y agoI'd rather just have a functions similar to clojure/clojurescript's get-in[0], update-in[1], assoc-in[2], dissoc-in[3] for working with nested objects/arrays. These are pretty easy to write in Python, Ruby, and Javascript, although I'm not aware of any public library that implements them. It really makes working with JSON-returning apis a breeze. [0] - http://clojuredocs.org/clojure_core/clojure.core/get-in http://clojuredocs.org/clojure_core/clojure.core/get-in [1] - http://clojuredocs.org/clojure_core/clojure.core/update-in http://clojuredocs.org/clojure_core/clojure.core/update-in [2] - http://clojuredocs.org/clojure_core/clojure.core/assoc-in http://clojuredocs.org/clojure_core/clojure.core/assoc-in [3] - http://clojuredocs.org/clojure_core/clojure.core/dissoc-in http://clojuredocs.org/clojure_core/clojure.core/dissoc-in
- ajanuary 12y agoThe authors JWalk is basically get-in. Lenses, as popularised by Haskell, solve a similar problem.
- chriswarbo 12y agoOr a Maybe functor http://functionaljavascript.blogspot.co.uk/2013/07/functors.html http://functionaljavascript.blogspot.co.uk/2013/07/functors....