Skip to content

Instantly share code, notes, and snippets.

@sonwh98
Created January 4, 2015 00:45
Show Gist options
  • Save sonwh98/980e7798ccfc0f1e84ad to your computer and use it in GitHub Desktop.
Save sonwh98/980e7798ccfc0f1e84ad to your computer and use it in GitHub Desktop.
implicit conversion of Scala String and Symbol to transit com.cognitect.transit.Keyword
import com.cognitect.transit.Keyword
import com.cognitect.transit.impl.KeywordImpl
implicit class ClojureKeyword(val sc:StringContext) extends AnyVal{
def k(args: Any*):KeywordImpl = {
val s = sc.raw(args.toSeq : _*)
new KeywordImpl(s)
}
}
implicit def symbol2keyword(s:Symbol):Keyword = new KeywordImpl(s.name)
val dbId: Keyword = k"db/id"
val name: Keyword = 'name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment