xiaozirun

dart 注释里看到一段有意思的内容 Dart>Go>Forward

  •  
  •   xiaozirun · Sep 27, 2024 · 2429 views
    This topic created in 780 days ago, the information mentioned may be changed or developed.

    在看 string 的 compareTo 方法注释时看到

    var relation = 'Dart'.compareTo('Go');
    print(relation); // < 0
    relation = 'Go'.compareTo('Forward');
    print(relation); // > 0
    relation = 'Forward'.compareTo('Forward');
    print(relation); // 0
    

    位置: https://github.com/dart-lang/sdk/blob/main/sdk/lib/core/string.dart#L256

    明白语言间没有好坏 合适就好 发出来就是图一乐哈哈

    第一次在官方注释中看到这样的内容

    6 replies  •  2024-09-27 10:50:45 +08:00
    geelaw
    geelaw
    Sep 27, 2024 via iPhone
    1
    通常来说 a.compareTo(b) < 0 用 a < b 表示,脑内模型应该是对于实数 a, b 有 a.compareTo(b) 和 (a - b) 的符号一样。

    所以应该写 Dart < Go < Forward = Forward 。
    geelaw
    geelaw
    Sep 27, 2024 via iPhone
    2
    @geelaw #1 眼拙我,应该是

    Dart < Go
    Go > Forward
    Forward = Forward
    darkengine
    darkengine
    Sep 27, 2024
    3
    同一份代码里:
    /// const string = 'Dart is fun';
    😂
    Bingchunmoli
    Bingchunmoli
    Sep 27, 2024 via Android
    4
    dart 语言主要用在哪方面啊,个人不是很常见
    Sezxy
    Sezxy
    Sep 27, 2024
    5
    @Bingchunmoli #4 flutter
    xiaozirun
    xiaozirun
    OP
    Sep 27, 2024
    6
    @darkengine 哈哈哈

    @geelaw #2 是哦 那应该 Go>Dart>Forward
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   5071 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 52ms · UTC 03:00 · PVG 11:00 · LAX 19:00 · JFK 22:00
    ♥ Do have faith in what you're doing.