Java Magazine, September/October 2017
ORACLE COM JAVAMAGAZINE SEPTEMBER OCTOBER 2017 68 jvm languages Finally I define my assertion via the is macro This macros body contains the some function which returns true if the value passed to it is not nil a value representing null or false otherwise Lastly I take the user data structure that I bound earlier and look up the value in the email key Whats with the Colon Clojure has support for an idea known as a keyword which should not be confused with the concept of reserved keywords in other languages including Java such as static or final Keywords are a great way to write expressive maps or pattern matching conditionals Plus when they are output they evaluate to a string version of themselves minus the colon When you write Clojure code you might find yourself using keywords frequently Keywords help me express and declare the intentions of the code that I write You can use keywords to define the keys in a map of user data or the values of a list ns demo hello keywords def brads details name Brad languages clojure java javascript Keywords are often compared to enums in Java Sometimes theyre used in the way that enums would be used but its also worth mentioning that there is no requirement that a keyword be defined at compile time or runtime You can actually even create a keyword out of a string during runtime using the keyword function In the previous example youll notice that the keywords name languages clojure java and javascript are all introduced by a colon Functional Concepts Clojure is predominantly a functional programming language As such it treats its code as a set of mathematical expressions and attempts to avoid changing state or mutating data Clojure
You must have JavaScript enabled to view digital editions.