Skip to main content
added 126 characters in body
Source Link
ClojureMostly
  • 4.8k
  • 2
  • 25
  • 24

This already works perfectly fine:

Note:

 public interface IFn extends Callable, Runnable public class Keyword implements IFn 

And then:

(defmulti print-stuff class) (defmethod print-stuff Callable [x] {:callable x}) (defmethod print-stuff :default [x] :not-found) (print-stuff :foo) ;; => :callable 

Note, multimethods always uses isa? internally on the (potentially custom) hierarchy. And (isa? Keyword Callable) is true.

This already works perfectly fine:

Note:

 public interface IFn extends Callable, Runnable public class Keyword implements IFn 

And then:

(defmulti print-stuff class) (defmethod print-stuff Callable [x] {:callable x}) (defmethod print-stuff :default [x] :not-found) (print-stuff :foo) ;; => :callable 

This already works perfectly fine:

Note:

 public interface IFn extends Callable, Runnable public class Keyword implements IFn 

And then:

(defmulti print-stuff class) (defmethod print-stuff Callable [x] {:callable x}) (defmethod print-stuff :default [x] :not-found) (print-stuff :foo) ;; => :callable 

Note, multimethods always uses isa? internally on the (potentially custom) hierarchy. And (isa? Keyword Callable) is true.

Source Link
ClojureMostly
  • 4.8k
  • 2
  • 25
  • 24

This already works perfectly fine:

Note:

 public interface IFn extends Callable, Runnable public class Keyword implements IFn 

And then:

(defmulti print-stuff class) (defmethod print-stuff Callable [x] {:callable x}) (defmethod print-stuff :default [x] :not-found) (print-stuff :foo) ;; => :callable