Back
starts-with? (clj)
(source)function
(starts-with? s substr)
True if s starts with substr.
Examples
clojure
(ns clojure.test-clojure.rt
(:require [clojure.string :as string]
clojure.set)
(:use clojure.test clojure.test-helper))
(deftest ns-intern-policies
(testing "you can replace a core name, with warning"
(let [ns (temp-ns)
replacement (gensym)
e1 (with-err-string-writer (intern ns 'prefers replacement))]
(is (string/starts-with? e1 "WARNING"))
(is (= replacement @('prefers (ns-publics ns))))))
(testing "you can replace a defined alias"
(let [ns (temp-ns)
s (gensym)
v1 (intern ns 'foo s)
v2 (intern ns 'bar s)
e1 (with-err-string-writer (.refer ns 'flatten v1))
e2 (with-err-string-writer (.refer ns 'flatten v2))]
(is (string/starts-with? e1 "WARNING"))
(is (string/starts-with? e2 "WARNING"))
(is (= v2 (ns-resolve ns 'flatten)))))
(testing "you cannot replace an interned var"
(let [ns1 (temp-ns)
ns2 (temp-ns)
v1 (intern ns1 'foo 1)
v2 (intern ns2 'foo 2)
e1 (with-err-string-writer (.refer ns1 'foo v2))]
(is (string/starts-with? e1 "REJECTED"))
(is (= v1 (ns-resolve ns1 'foo))))))
clojure
(ns clojure.test-clojure.string
(:require [clojure.string :as s])
(:use clojure.test))
(deftest t-starts-with?
(is (s/starts-with? (StringBuffer. "clojure west") "clojure"))
(is (not (s/starts-with? (StringBuffer. "conj") "clojure"))))
metabase/metabase
(ns change.strict
(:require
[clojure.spec.alpha :as s]
[clojure.string :as str]
[column.strict]))
;; createIndex *must* include an explicit index name.
(s/def ::indexName
#(str/starts-with? % "idx_"))
nextjournal/clerk
(ns user
(:require [clojure.string :as str]
[nextjournal.clerk :as clerk]))
;; start with file watcher and show filter function to enable notebook pinning
(clerk/serve! {:watch-paths ["notebooks" "src"] :show-filter-fn #(clojure.string/starts-with? % "notebooks")})
clj-kondo/clj-kondo
(ns unused-referred-var
(:require [clojure.string :refer [starts-with? ends-with?]]))
(starts-with? "foo" "f")
clj-kondo/clj-kondo
(ns no-unused-namespace
(:require [clojure.string :as str]))
(let [{score (if (str/starts-with? "foo" "f")
:starts-with :not-starts-with)}
{:starts-with 100
:not-starts-with 0}]
score) ;;=> 100
liquidz/antq
(ns antq.diff.java
(:require
[antq.diff :as diff]
[antq.log :as log]
[antq.util.dep :as u.dep]
[antq.util.git :as u.git]
[antq.util.url :as u.url]
[clojure.string :as str]))
(defmethod diff/get-diff-url :java
[{:as dep :keys [version latest-version]}]
(when-let [url (u.dep/get-scm-url dep)]
(cond
(str/starts-with? url "https://github.com/")
(let [current (u.git/find-tag url version)
latest (or (u.git/find-tag url latest-version)
;; If there isn't a tag for latest version
"head")]
(if current
(format "%scompare/%s...%s"
(u.url/ensure-tail-slash url)
current
latest)
(do (log/warning (str "The tag for current version is not found: " url))
;; not diff, but URL is useful for finding the differences.
nil)))