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. python代码大全表解释-【初学】Python异常代码含义对照表
  2. 【转载】eclipse常用插件在线安装地址或下载地址
  3. ConneR and the A.R.C. Markland-N CodeForces - 1293A(暴力)
  4. 120xa正反转参数_你知道变频器的“正反转死区时间”吗?它的“停机方式”有几种?...
  5. 微信昵称包含emoji表情,保存异常
  6. js使用的一些实用技巧
  7. Halo2 Map Editor Error
  8. boolean到底占几个字节?
  9. 【免费看电视-直接看电视方法】打开电视发现看啥都要Vip?解决方法:
  10. 快速在越狱iphone手机下定位app安装包并且导出的方法
  11. 【蓝桥杯单片机组模块】13、NEC 红外通信 - vs1838B
  12. js金额小写转换成大写
  13. django运行错误:wrong number of arguments for ‘set‘ command
  14. 分析时间复杂度,主定理,势能分析
  15. 太过伤心,小王被这 10 道 Java 面试题虐哭了
  16. win7 计算机无法搜索,Win7电脑搜索功能不能用的解决方法
  17. 回忆--上海滩奋斗的日子
  18. 加强膝关节周围肌肉力量的九个简单动作练法
  19. Android 逆向初探
  20. 基于PCA的人脸识别_Matlab实现(个人研读之后的一些总结)

热门文章

  1. [转载] python 动态变量创建locals()
  2. [转载] python如何删除对象属性_Python3基础 delattr 删除对象的属性
  3. [转载] python中的numpy模块和pandas模块的区别_numpy 模块和 pandas 模块
  4. Day04:循环结构(while、do-while、for)
  5. 第一次作业+105032014142
  6. javascript中的对象之间继承关系
  7. Xfire的aegis绑定方式配置小结
  8. (二)OpenCV Mat常用属性和方法
  9. LabView学习笔记(八):属性节点
  10. cartographer编译过程遇到未定义的dlclose@@GLIBC_2.2.5