V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
cosmozs
V2EX  ›  程序员

moonbit 支持字符串模式匹配,你们觉得有必要吗

  •  
  •   cosmozs · 39 天前 · 739 次点击
    这是一个创建于 39 天前的主题,其中的信息可能已经有所发展或是发生改变。

    支持 Unicode 安全的字符串前缀和后缀模式匹配

    fn match_str(s: String) -> Unit {
      match s {
        "hello" => ... // string literal pattern
        [ 'a' ..= 'z', ..rest ] => ... // array pattern
        [ .., '😭' ] => ... // array pattern with unicode
        _ => ...
      }
    }
    

    大家怎么评价?

    1 条回复    2025-02-20 22:23:52 +08:00
    NerdHND
        1
    NerdHND  
       39 天前
    moonbit 的字符串和 Haskell 一样是 char list 吗?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5197 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 05:49 · PVG 13:49 · LAX 22:49 · JFK 01:49
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.