I mean commands like :t
:type
to check type of expressions or any other kinds of commands.
The idea behind ammonite really attracts me and now I'm trying to use it to get more familiar with scala.
These commands are helpful to me as a beginner, but are syntax errors in amm shell.
I've gone through the documentation of ammonite.io but cann't find anything related mentioned.
Is it possible to run these kind of commands in ammonite shell/repl ?
You cannot run Scala REPL commands in Ammonite, because they are Scala REPL commands, not Ammonite commands.
Ammonite is a completely different program from the Scala REPL, its command language is different. This is like trying to run Haskell code in a JavaScript REPL.
In particular, Ammonite prefers using Scala over a magic separate command language, so in Ammonite commands to the REPL are issued as normal Scala method calls.
There are two objects that are imported by default, repl
and interp
, that allow you to interact with the API of the REPL and the interpreter. For example, for your question about how to get the type of an object, you would use the ReplAPI.typeOf[T: WeakTypeTag](t: => T): Type
method:
repl.typeOf("3" + 2)
//=> res: reflect.runtime.package.universe.Type = TypeRef(ThisType(package lang), class String, List())