2.scala编程思想笔记——运行Scala

2.scala编程思想笔记——运行Scala

       欢迎转载,转载请标明出处:http://blog.csdn.net/notbaron/article/details/50444091
源码下载连接请见第一篇笔记。

  Scala解释器也成为REPL(Read-Evaluate-Print-Loop,读取-计算-打印-循环)

按照上节配置环境后,输入scala就进入了REPL。如下:

         [root@localhostexamples]#scala

Welcome to Scala version 2.11.7 (OpenJDK64-Bit Server VM, Java 1.7.0_51).

Type in expressions to have them evaluated.

Type :help for more information.

 

scala>

 

1.  算术运算如下:

scala> 43*11.3

res0: Double = 485.90000000000003

其中res0表示计算结果命名

Double表示双精度浮点数

2.  帮助

输入Help可以获得更多信息如下:

scala> :help

All commands can be abbreviated, e.g., :heinstead of :help.

:edit <id>|<line>        edit history

:help [command]          print this summary orcommand-specific help

:history [num]           show the history (optional num iscommands to show)

:h? <string>             search the history

:imports [name name ...] show importhistory, identifying sources of names

:implicits [-v]          show the implicits in scope

:javap <path|class>      disassemble a file or class name

:line <id>|<line>        place line(s) at the end of history

:load <path>             interpret lines in a file

:paste [-raw] [path]     enter paste mode or paste a file

:power                   enable power user mode

:quit                    exit the interpreter

:replay [options]        reset the repl and replay all previouscommands

:require <path>          add a jar to the classpath

:reset [options]         reset the repl to its initial state,forgetting all session entries

:save <path>             save replayable session to a file

:sh <command line>       run a shell command (result isimplicitly => List[String])

:settings <options>      update compiler options, if possible; seereset

:silent                  disable/enable automaticprinting of results

:type [-v] <expr>        display the type of an expressionwithout evaluating it

:kind [-v] <expr>        display the kind of expression's type

:warnings                show the suppressed warningsfrom the most recent line which had any

3.  注释:

注释是说明性的文本

使用//开头的注释,直到当前行末尾

多行注释用/*开头  */ 结束。

和C语言基本一致。

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值