Destructuring is so meta


This is sort of a combo category, an actual technical question and a suggestion that we add a category for Raw Noob Help or something along those lines. I can sort of, kind of, barely follow most of the questions posted to the discussion boards, so as a raw beginner, I feel a little bit embarrassed asking for help on something that feels, relatively speaking, stupefyingly basic. Nevertheless, I will press on anyway and carry the torch for the very small inner club of mouth-breathing noobs (current population: 1). To wit:

Trying to learn some very basic destructuring and I think I’ve put this together correctly, but the result that comes back at me when I try to run the function is “nil.” Totally not what I was going for. Could I get another pair of eyes on this to tell me what I’m missing, please?

(defn choosey
  [[first-up second-up & whatevers]]
  (println (str "Your first choice is: " first-up))
  (println (str "Your second choice is: " second-up))
  (println (str "Nobdy cares about the rest. "
                "But, for the record, here are the also-rans: "
                (clojure.string/join ", " whatevers))))

(choosey ["chocolate" "gum" "cookies" "pizza" "hard candy"])


Anyone else get the same thing or is it working properly for you? I’m using Light Table as my editor/repl and I am not sure if it’s just a matter of LightTable just kicking back the last value???


Hi @snuffaluffagus,

This question is totally welcome here! I hope to make this a place where people can feel free to ask any question, no matter how basic it may seem. We’re all learning.

So, it seems to work on mine. You can see the prompts (exploratorium.core>), the printouts, and then the return (nil).

exploratorium.core> (choosey ["chocolate" "gum" "cookies" "pizza" "hard candy"])
Your first choice is: chocolate
Your second choice is: gum
Nobdy cares about the rest. But, for the record, here are the also-rans: cookies, pizza, hard candy

The reason it’s returning nil is that functions return the value of their last expression. In this case, it’s a println, and println always returns nil.

It looks like your destructuring is working correctly. I’m not sure what light table is doing with the println output, which typically goes to standard out. Can you check in Light Table’s repl?



Aha! Thanks so much for confirming it’s a LightTable thing. I’ve just been using str to print strings, so this is my first time messing with println. Not sure if I’m supposed to be using some other plugin to get it to spew the whole deal, but I guess this is the incentive I needed to install and get comfortable with Cursive (yes, I’m purposefully trying to avoid emacs and the whole Lord of the Rings journey to a proper set up). There are no shortcuts. There are no shortcuts.


LightTables’ instarepl indeed doesn’t show the content of standard output which println writes to. It only shows the return value of the expression that is evaluated.
And if you are not already familiar with emacs, you will be better off with Cursive to start to avoid learning two (large) things at the same time.


+1 on using Cursive, from another mouth-breathing (and sometimes knuckle-dragging) noob