Rant about strings. About comment, and work around to comment multimethods
Code
;; commenting_stuff.clj
(def var1 "He said \"Hello\" to me")
var1
;; (def var2 """He said "Hello" to me""")
;; var2
;; (defn some-method
;; (clojure.core/comment "this is a comment")
;; []
;; (println "hello"))
;; (some-method)
(comment
(*
(+ 2 3)
7))
(clojure.core/comment
(*
(+ 2 3)
7))
(*
(+ 2 3)
7)
(clojure.core/comment
(defn foo [x]
(inc x)))
(comment)
(defn another-method
"this is a comment"
[]
(println "hello"))
(another-method)
(doc another-method)
(defn arg-type [arg]
(cond
(string? arg) :string
(number? arg) :number
:else :other))
(arg-type "hello")
(arg-type 1)
(defn dispatcher [args]
(map arg-type args))
(dispatcher ["hello" 1])
(dispatcher [1 2])
(dispatcher ["hello" "world"])
(defmulti multi-add (fn [& args] (dispatcher args)))
(defmethod multi-add '(:number :number) [a b]
(+ a b))
(defmethod multi-add '(:string :string) [a b]
(str a b))
(defn add
"Adds two strings or nubers.
Usage
----------
```clojure
(add 1 2)
(add \"a\" \"b\")
```
"
[a b]
(multi-add a b))
(doc add)
(add 1 2)
(add "a" "b")
Notes
-
Slack chats (Not accessible publicly)
- Wish all Clojure moved to Zulip