ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
还可以根据匿名结构的字段和实例进行匹配: > It is also possible to match against the fields of anonymous structures and instances: ~~~ var myStructure = { name: "haxe", rating: "awesome" }; var value = switch(myStructure) { case { name: "haxe", rating: "poor" }: throw false; case { rating: "awesome", name: n }: n; case _: "no awesome language found"; } trace(value); // haxe ~~~ 在第二种情况,如果评定匹配 “awesome”我们绑定匹配的 name 字段 为标识符 n,。当然这个结构也可以被放入前一个例子中的 Tree 来联合结构和枚举匹配。 > In the second case we bind the matched name field to identifier n if rating matches "awesome". Of course this structure could also be put into the Tree from the previous example to combine structure and enum matching. 类实例的一个限制是,不能匹配它们父类的字段。 > A limitation with regards to class instances is that you cannot match against fields of their parent class.