Fork me on GitHub
#beginners
<
2017-01-28
>
eslachance02:01:33

Ok I've got another fairly dumb question. I have this structure (hashmap?)

{:user {:username "TypicalBot Beta", :id "212016587358601216", :discriminator "5353", :bot true, :avatar "429b59c5cda82f9088e3c076b131913a"}, :roles [], :mute false, :joined_at "2017-01-28T02:56:20.799796+00:00", :guild_id "271063738164051980", :deaf false}
I'm attempting to get the username, and ID, from it (separately) (get member :user :username) only outputs the whole user structure. (get-in member :user :username) gives me an illegal argment exception "Don't now how to create ISeq from keyword"

eslachance02:01:38

what am I missing here 😞

fingertoe03:01:18

(:username (:user datastructure)) works for me.

eslachance03:01:39

Ah so reverse then

eslachance03:01:45

the "other" way

eslachance03:01:19

I thought get-in was supposed to do that though

fingertoe03:01:21

Yep, You want to find the :username out of the result structure of the :user function..

eslachance03:01:28

Returns the value in a nested associative structure, where ks is a sequence of keys. Returns nil if the key is not present, or the not-found value if supplied.

eslachance03:01:28

The wording. I gotta get used to the wording. sequence of keys. (get-in member [:user :username]) of course

eslachance03:01:31

I knew it was a derp

abhir00p07:01:12

@eslachance (get member :user :username) This doesn’t work for you is because if you look at the docs of get it looks like this (get map key not-found)

abhir00p07:01:49

So basically you are implying get me the :user key from member and if it is not found then return the keyword :username

abhir00p07:01:03

Also get-in doesn’t work for you because get-in takes a vector as the third argument. But I guess you got that figured

sif18:01:49

Hi! is there any difference between for example (var +) and (resolve '+) as they both seem to return the same var #'clojure.core/+? when do they differ :thinking_face:?