I want to be able to get as most as possible information about a variable. So I wonder, is there a function in Scala, which is pretty much like inspect
or p
methods in Ruby?
Asked
Active
Viewed 160 times
2

Incerteza
- 32,326
- 47
- 154
- 261
-
1It's not clear what you are asking. On the one hand, you say that you want "information about a variable", on the other hand you mention `Object#inspect` and `Kernel#p` which don't give information about variables *at all*, they only give information about *objects*, and variables aren't objects, neither in Ruby nor Scala. – Jörg W Mittag Oct 19 '13 at 12:00
-
@JörgWMittag: methinks it's safe to assume OP meant object, rather than variables. – Denis de Bernardy Oct 19 '13 at 12:37
-
@Alex: see http://stackoverflow.com/questions/2272705/how-to-debug-scala-code-when-outside-of-an-ide and http://stackoverflow.com/questions/2160355/drop-into-interpreter-during-arbitrary-scala-code-location/ – Denis de Bernardy Oct 19 '13 at 12:38
-
@JörgWMittag - `p @var123` - doesn't this print the information about the variable? – Incerteza Oct 19 '13 at 16:01
-
No, it dereferences the variable, calls `inspect` on the object that is referenced by the variable and prints *that*. It *cannot possibly* print any information about the variable, because Ruby is an object-oriented language and you can only manipulate objects, but variables *aren't* objects. – Jörg W Mittag Oct 19 '13 at 16:04