scala 连接符

The names of variables, classes, objects and methods are collectively called Identifiers. Scala identifiers are case sensitive. We have been using identifiers all through the tutorial series. Let us now see them in more detail.

变量,类,对象和方法的名称统称为标识符Scala标识符区分大小写。 在整个教程系列中,我们一直在使用标识符。 现在让我们更详细地了解它们。

Scala标识符类型 (Scala Identifiers Types)

  1. AlphaNumeric Identifiers字母数字标识符
  2. Alphanumeric identifiers start with a letter or underscore that can be further followed by digits, letters or underscores. The $ character is reserved keyword and cannot be used as identifiers.

    字母数字标识符以字母或下划线开头,后跟数字,字母或下划线。 $字符是保留关键字,不能用作标识符。

    For example sage,sname,_id etc.. are valid identifiers.

    例如,sage,sname,_id等是有效的标识符。

    $age, -id, 45name are invalid identifiers.

    $ age,-id,45name是无效的标识符。

    object alphanumeric {
    def main(args:Array[String]) {val  sage = 8 ;val sname = "Rob";println("Age :"+sage)println("Name:"+sname)
    }
    }

    When executed main method, it produces below output.

    执行main方法时,将产生以下输出。

    Age :8
    Name:Rob

    Here the variables sage and sname are legal identifiers of Integer and String data types.

    在这里,变量sage和sname是Integer和String数据类型的合法标识符。

  3. Operator identifiers操作员标识符
  4. An operator consists of one or more operator characters. Operator characters include +, :, ?, ~ or # .

    一个运算符由一个或多个运算符组成。 运算符包括+,:,?,〜或#。

    For example + , – , => :::

    例如+,–,=> :::

    object Operator {
    def main(args:Array[String]) {val a =10 ;val b=42;val c = a + b ;val d = b -a ;println("Result of + operator identifier: "+c);
    println("Result of - identifier: "+d);}
    }

    Output:

    输出:

    Result of + operator identifier: 52
    Result of - identifier: 32

    In the above example +, – are the operator identifiers which adds and subtracts the variables and prints the result.

    在上面的示例中,+,-是运算符标识符 ,用于添加和减去变量并输出结果。

  5. Mixed Identifiers混合标识符
  6. A mixed identifier contains alphanumeric character followed by underscore and an operator identifier.

    混合标识符包含字母数字字符,后跟下划线和运算符。

    Example unary_+ , myVar_=

    示例unary_ +,myVar_ =

    object Mixed {def main(args:Array[String]) {val marks_+ = 50;println(marks_+);}
    }

    Output:
    50

    输出
    50

    In the above example marks_+ is a mixed identifier.

    在上面的示例中,marks_ +是混合标识符。

  7. Literal identifiers文字标识符
  8. A literal identifier is an arbitrary string enclosed with back ticks (`……`) .

    文字标识符是用反引号(`……`)括起来的任意字符串。

    For example; `age` `name` etc are literal identifiers

    例如; `age`name`等是文字标识符

    object Literal {def main(args:Array[String]) {val `x` = 10;val `message` = "Hello"println(`x` + "\n" + `message`);}
    }

    Output:
    10
    Hello

    输出:
    10
    你好

    Here the variables x and message are enclosed with back ticks indicating the literal identifiers.

    这里,变量x和message用反斜线括起来,指示文字标识符。

That’s all for a quick roundup on Scala identifiers, we will look into regular expressions in scala in next tutorial.

这就是对Scala标识符的快速汇总,我们将在下一个教程中研究scala中的正则表达式。

翻译自: https://www.journaldev.com/8170/scala-identifiers-example-tutorial

scala 连接符

scala 连接符_Scala标识符示例教程相关推荐

  1. scala数据类型_Scala数据类型示例教程

    scala数据类型 A data type tells the compiler about the type of the value to be stored in a location. The ...

  2. scala特性_Scala特性示例教程

    scala特性 Scala Traits consists of method and field definitions that can be reused by mixing classes. ...

  3. scala代码示例_Scala数组示例

    scala代码示例 Scala supports the array data structure. An array is a fixed size data structure that stor ...

  4. scala代码示例_Scala集合示例

    scala代码示例 Scala Collections are the containers that hold sequenced linear set of items like List, Se ...

  5. 链接符计算机,excel中连接符的使用教程全解

    Excel中的连接符具体该如何使用呢?下面是学习啦小编带来的关于excel中连接符的用法,希望阅读过后对你有所启发! excel中连接符的用法 连接符使用步骤1:例如你的工作是记录机器运转的情况,以电 ...

  6. php 连接符.,PHP怎么在数字之间添加连接符

    PHP实现数字之间添加连接符,我们可以通过PHP中的for循环思想来实现.这里的连接符指的是"-"符号. 推荐参考:<PHP教程> 那么对于新手来说,可能有一定难度. ...

  7. Spring MVC Hibernate MySQL集成CRUD示例教程

    Spring MVC Hibernate MySQL集成CRUD示例教程 我们在上一篇教程中学习了如何集成Spring和Hibernate.今天,我们将继续前进,并将Spring MVC和Hibern ...

  8. Primefaces,Spring 4 with JPA(Hibernate 4 / EclipseLink)示例教程

    Primefaces,Spring 4 with JPA(Hibernate 4 / EclipseLink)示例教程 Java Persistence API是标准规范.它提供了一个由不同实现者框架 ...

  9. Java设计模式 - 示例教程

    Java设计模式 - 示例教程 设计模式在软件开发人员中非常流行.设计模式是针对常见软件问题的良好描述的解决方案.我已经写了很多关于java设计模式的文章.您可以订阅我们的时事通讯下载PDF电子书(1 ...

最新文章

  1. 量化延时法时间测量_「交易技术前沿」交易系统低延时测试与分析
  2. Hadoop-2.7.4 八节点分布式集群安装
  3. boost::property_map用法的测试程序
  4. CVE-2012-1876调试要点
  5. ediplus 复制编辑一列_vi编辑器的使用详解
  6. shell脚本传可选参数 getopts 和 getopt的方法
  7. Python字符串模糊匹配库FuzzyWuzzy
  8. 在MAC下怎样用SSH连接远程LINUXserver
  9. linux运行脚本运行不了,解决linux 运行自动化脚本浏览器无法启动问题
  10. 网易:层次遍历二叉树
  11. NOIP 2005 等价表达式 (TYVJ P1060)
  12. 不要效法世界只要爱天父
  13. Java 中的十大排序算法
  14. 怎么看计算机电源型号,电脑电源铭牌怎么看?台式机电源铭牌知识扫盲 拒绝虚标!...
  15. 2022安好? 2023何如?
  16. 借助云开发,利用订阅消息,云函数路由实现小程序好友一对一聊天,添加好友等仿微信功能
  17. 《30天自制操作系统》---第一天
  18. Cg Programming/Unity/Specular Highlights镜面高光
  19. 日志说明以及格式统一规范
  20. EU Long-term Dataset with Multiple Sensors for Autonomous Driving

热门文章

  1. 朋友,决定了就去做.
  2. asp.net页面调用cs中的方法
  3. __new__()方法的使用和实例化
  4. VMware Workstation 无法与 Windows XP \ Windows 7 \ Windows 8 进行共享文件夹。
  5. 《Python核心编程》第二版第308页第十一章练习 续一 -Python核心编程答案-自己做的-...
  6. 深度学习——卷积块回顾
  7. 数据结构笔记(二十三)--哈夫曼树
  8. 使用php函数判断数字,PHP 几个常用数字判断函数的简单示例
  9. c++ 23种设计模式_如何用一句话总结23种设计模式
  10. mysql 字段有正负值的时候 sum无效_京东金融数据分析:MySQL+HIVE的结合应用案例详解...