2016-02-17 44 views
1

我正在嘗試此功能(開始與?)顯示在這裏:https://clojure.github.io/clojure/clojure.string-api.html,當我嘗試使用它時,我得到Unable to resolve symbol: starts-with? in this context錯誤消息。我通過指定:dependencies [[org.clojure/clojure "1.8.0"]]來修改我的項目依賴關係,但這似乎沒有幫助。使用starts-with?功能

+2

你將需要在源代碼文件的引用,以及:'(:要求[clojure.string:如STR])',然後'STR /開始-用'是?函數的名稱。 –

+1

或者,如果你只需要這個函數一次,輸入它的全名,不需要':'(clojure.string/starts-with?「hello world」「hello」)'。 – glts

回答

6

您可能忘記了要求命名空間?請參見下面的示例:

(ns simple.strings 
    (:require [clojure.string :as str])) 

(str/starts-with? "hello, world" "hello") 
; true 
+0

我也沒有想到要使用.startsWith –