In python:
>>> s = "abc"
>>> dir(s)
['__add__', '__class__', '__contains__', '__delattr__', ...
Is there an equivalent way - i.e. dir() function - to do this with instances in the scala REPL ?
When you press the tabulator-key the REPL shows you the methods which you can call on an object:
scala> val s = "abc"
s: java.lang.String = abc
scala> s.<tab>
+ asInstanceOf charAt
codePointAt codePointBefore codePointCount
compareTo compareToIgnoreCase concat
contains contentEquals endsWith
equalsIgnoreCase getBytes getChars
indexOf intern isEmpty
isInstanceOf lastIndexOf length
matches offsetByCodePoints regionMatches
replace replaceAll replaceFirst
split startsWith subSequence
substring toCharArray toLowerCase
toString toUpperCase trim
For more information about the REPL look here.
Why tab-completion is more adequate as a help from within REPL (and it shows the parameters too, once you have written the method name!), the technical equivalent to dir
is:
s.getClass.getMethods
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With