kibit icon indicating copy to clipboard operation
kibit copied to clipboard

Bad advice for `constantly` anonymous function

Open saeidscorp opened this issue 8 years ago • 3 comments

Isn't this wrong?

Consider using:
   page
instead of:
   (fn [] [page])

Shouldn't it be (constantly page)? (or (constantly [page]))?

saeidscorp avatar Nov 27 '16 07:11 saeidscorp

Can you give the full code context for this?

danielcompton avatar Nov 27 '16 20:11 danielcompton

Sure... It's ClojureScript:

(ns myapp.cc.core
  (:require [reagent.core :as reagent :refer [atom]]
            [myapp.helper :as h]
            [ajax.core :refer [GET]]))

(defn ^:export main []
      (init-state)
      (reagent/render-component (fn [] [page]) (h/get-elem "app")))

And the definition of myapp.helper/get-elem:

(defn get-elem [id] (goog.dom/getElement id))

saeidscorp avatar Nov 27 '16 21:11 saeidscorp

I suspect it's related with this issue

https://github.com/jonase/kibit/issues/174

Can't find the rule that defines that equivalence though..

AndreaCrotti avatar Mar 05 '17 13:03 AndreaCrotti