zoukankan      html  css  js  c++  java
  • Scala-操作符

    1、单元操作符,中置操作符,双元操作符,后置操作符

    object Operation {
    
      def main(args: Array[String]): Unit = {
        //中置操作符 + to.....
        //单元操作符 tostring
        val  s =  1.toString;
    
        //!时布尔值取反
        val  flg = !true;
        println(flg);
        //~按位取反
        val s1 =  ~100;
        println(s1);
    
      }
    
    }
    

    2、操作符优先级
    Scala中除了冒号都是左结合的。

    object Operation {
    
      def main(args: Array[String]): Unit = {
    
        //Nil表示一个空的集合
        println(1::2::(4::Nil));
    
        println(Nil.::(7));
        /*
        List(1, 2, 4)
      List(7)
         */
      }
    
    }
    
    欢迎关注我的公众号:小秋的博客 CSDN博客:https://blog.csdn.net/xiaoqiu_cr github:https://github.com/crr121 联系邮箱:rongchen633@gmail.com 有什么问题可以给我留言噢~
  • 相关阅读:
    php数组
    php数组排序
    php超级全局变量
    php循环
    php函数
    PHP魔术常量
    php面向对象
    static 关键字
    Final 关键字
    内置函数
  • 原文地址:https://www.cnblogs.com/flyingcr/p/10327098.html
Copyright © 2011-2022 走看看