Last active
May 22, 2018 14:33
-
-
Save dajobe/7586938 to your computer and use it in GitHub Desktop.
Get the methods on a class / object - aka python dir()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Inspired by http://stackoverflow.com/questions/2886446/how-to-get-methods-list-in-scala | |
def dir(x: AnyRef): Unit = println(x.getClass.getMethods.map(_.getName).distinct.sorted.mkString(" ")) | |
scala> dir("") | |
charAt codePointAt codePointBefore codePointCount compareTo compareToIgnoreCase concat contains contentEquals copyValueOf endsWith equals equalsIgnoreCase format getBytes getChars getClass hashCode indexOf intern isEmpty lastIndexOf length matches notify notifyAll offsetByCodePoints regionMatches replace replaceAll replaceFirst split startsWith subSequence substring toCharArray toLowerCase toString toUpperCase trim valueOf wait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey sorry to bother, but why AnyRef instead of Any?