我已经搜索了一会儿,但找不到任何例子来演示在匹配案例类时使用@_*的用法。
以下是我提到的那种申请的例子。
def findPerimeter(o: SomeObject): Perimeter = o match {
case Type1(length, width) =>
new Perimeter(0, 0, length, width)
case Type2(radius) =>
new Perimeter(0, 0, 2*radius, 2*radius)
...
case MixedTypes(group @_*) => {
\How could @_* be used to check subpatterns of group?
I'm sorry, you forgot to provide the text that needs to be translated. Please provide the text and I'll be happy to assist you.
I'm sorry, you forgot to provide the text that needs to be translated. Please provide the text and I'll be happy to assist you.
如果有人能展示给我一些例子或者指引我到一个网站,那就太好了。
谢谢 (xiè xiè)