Create a gist now

Instantly share code, notes, and snippets.

@matstani /core.clj
Last active Oct 24, 2017

Embed
What would you like to do?
try core.typed
(ns try-typed.core
(:require [clojure.core.typed :refer :all]))
; String型の引数をとりnilを返す
(ann foo [String -> nil])
(defn foo
"I don't do a whole lot."
[x]
(println x "Hello, World!"))
(ns try-typed.core
(:require [clojure.core.typed :refer :all]))
(ann foo [String -> nil])
(defn foo
"I don't do a whole lot."
[x]
(println x "Hello, World!"))
(ann call-foo [-> nil])
(defn call-foo []
; 型情報[String -> nil]と異なる呼出し
(foo 1.5))
(ns try-typed.core
(:require [clojure.core.typed :refer :all]))
(ann inc-str [String -> AnyInteger])
(defn inc-str
[s]
;incにStringが渡される
(inc s))
(ns try-typed.core
(:require [clojure.core.typed :refer :all]))
(ann inc-str [String -> AnyInteger])
(defn inc-str
[s]
;StringをIntegerに変換
(let [i (Integer/parseInt s)]
(inc i)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment