Skip to content

Instantly share code, notes, and snippets.

@kosugi
Last active January 3, 2016 12:24
Show Gist options
  • Select an option

  • Save kosugi/791f2fdcd9065592e807 to your computer and use it in GitHub Desktop.

Select an option

Save kosugi/791f2fdcd9065592e807 to your computer and use it in GitHub Desktop.
“dir” command in REPL in scala.
def typeOf(obj: Any) = scala.reflect.runtime.currentMirror.reflect(obj).symbol.typeSignature
def _format(xs :Iterable[Any]) = xs.map(_.toString).toList.distinct.sorted.foreach(println)
def members(obj: Any) = _format(typeOf(obj).declarations)
def classes(obj: Any) = _format(typeOf(obj).baseClasses)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment