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

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

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

    支持 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  
       43 天前
    moonbit 的字符串和 Haskell 一样是 char list 吗?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2326 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 06:35 · PVG 14:35 · LAX 23:35 · JFK 02:35
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.