zoukankan      html  css  js  c++  java
  • flutter runtimeType

    通过runtimeType可以获取当前数据类型

      var a = 10;
      var b = 10.0;
      var c = '10';
      var d = true;
      var e = [12.5,13.1];
      var f = {3:'5',5:'11'};
      var t = new Test();// 这里就直接使用上面那个Test类 不再去重复写这个类了
      print('a 的类型是: ${a.runtimeType}'); // a 的类型是: int
      print('b 的类型是: ${b.runtimeType}'); // b 的类型是: double
      print('c 的类型是: ${c.runtimeType}'); // c 的类型是: String
      print('d 的类型是: ${d.runtimeType}'); // d 的类型是: bool
      print('e 的类型是: ${e.runtimeType}'); // e 的类型是: List<double>
      print('f 的类型是: ${f.runtimeType}'); // f 的类型是: _InternalLinkedHashMap<int, String>
      print('t 的类型是: ${t.runtimeType}'); // t 的类型是: Test
    class Test{}
    

    比如一个类 Test

     var t = new Test();
     
     t.runtimeType = Test
    
  • 相关阅读:
    矩阵乘法优化求斐波那契
    高斯消元
    NOIP201305转圈游戏
    双六问题
    线段上格点的个数
    如何写出优雅的Python代码?
    sock.listen()
    python socket编程
    sc,sockname = sock.accept()
    格式化字符
  • 原文地址:https://www.cnblogs.com/qqcc1388/p/11463550.html
Copyright © 2011-2022 走看看