Fork me on GitHub
#beginners
<
2017-09-27
>
javazquez02:09:14

is the expected behavior for defaults via ':or' not to be bound to :as ? (defn test-defaults [{:keys [ one two three], :or {three 3} :as params}] params ) (println (test-defaults {:one 1 :two 2})) was expecting to see {:one 1, :two 2 :three 3} but got {:one 1, :two 2}

noisesmith02:09:26

:as should always return precisely the original arg before destructuring

javazquez02:09:26

ok. thank you!

madstap02:09:59

You can use destructure to see what's happening.

javazquez02:09:45

I didn't know about destructure. That is fantastic!

qle-guen09:09:42

why does (update '(0 0) 0 inc) throws NullPointerException?

sundarj09:09:37

lists aren't indexed

sundarj09:09:00

you'd want a vector

qle-guen09:09:53

ok, it's odd that (nth '(0 0) 0) works though

sundarj09:09:49

update is for updating things by key (index), nth is simply for getting the nth item out of something, so it works with lists. guess it's a fine distinction but there you go

sundarj09:09:00

nth also works on lazy seqs, for instance

qle-guen09:09:45

ah ok, makes sense

miyurz09:09:11

I am a noob here

hmaurer09:09:52

@mayur.nagekar Hi noob o/

miyurz09:09:10

👋 @hmaurer

genec10:09:28

is it possible to create more than one namespace in a file or to create nested namespaces in the same file in Clojure? I'm coming from F#/.NET where this is a pretty common thing to do.

didibus04:09:17

Its uncommon in Clojure, even though it is supported, a lot of tooling assume you're not doing that, and so might behave strangely on your files.

sundarj10:09:53

@genec pretty sure more than one namespace in a single file is supported - don't think nested namespaces are possible though

gmercer11:09:24

@ghadi you mentioned official clojure launcher available on homebrew - what is the name ?

alexmiller12:09:17

@gmercer it’s called “clojure” :) brew install clojure (for 1.8.0) or brew install --devel clojure (for 1.9.0-beta1). See https://clojure.org/guides/deps_and_cli

genec12:09:49

@sundarj thanks

gmercer12:09:11

@alexmiller I saw that from a search - seemed too obvious 😉

gmercer12:09:27

and thanks

alexmiller12:09:51

still a wip… :)

guy16:09:46

I've got a silly question

guy16:09:01

What do you get when you do

(read-string "050")

dpsutton16:09:16

leading zero means octal i believe

guy16:09:29

yeah thats what i learnt today too haha

guy16:09:32

you get 40

dpsutton16:09:44

(Integer/parseInt "050") => 50

guy16:09:59

Yeah thanks man 👍

dpsutton16:09:19

if you evaluate 050 you'll see 40

bfabry17:09:17

the octal thing has bitten me in more languages than I'd care to mention