Last active
October 24, 2017 02:42
-
-
Save matstani/6420121 to your computer and use it in GitHub Desktop.
try core.typed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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!")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns try-typed.core | |
(:require [clojure.core.typed :refer :all])) | |
(ann inc-str [String -> AnyInteger]) | |
(defn inc-str | |
[s] | |
;incにStringが渡される | |
(inc s)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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