On Tue, Dec 21, 2010 at 12:23 AM, Sean Corfield <seancorfi...@gmail.com>wrote:
> On Mon, Dec 20, 2010 at 7:54 PM, Stephen Pardue > <pardue.step...@gmail.com> wrote: > > (defn panda [x] > > (case (type x) > > java.lang.String "HELLZ YEAH IT'S A STRING!" > > java.lang.Integer "it's an integer..")) > > Since (type x) returns a Class object, you could do this: > > user=> (defn panda[x] (case (.getName (type x)) > "java.lang.String" "HELLZ YEAH IT'S A STRING!" > "java.lang.Integer" "it's an integer..")) > #'user/panda > user=> (panda 6) > "it's an integer.." > user=> (panda "apple") > "HELLZ YEAH IT'S A STRING!" > user=> > -- > Sean A Corfield -- (904) 302-SEAN > Railo Technologies, Inc. -- http://getrailo.com/ > An Architect's View -- http://corfield.org/ > > "If you're not annoying somebody, you're not really alive." > -- Margaret Atwood But of course that will use reflection which probably defeats the purpose of using case which dispatches very quickly. David -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en