`forSome`的所有用法是否可以被等效的`_`替代? [英] Can all usages of `forSome` be replaced by an equivalent usage of `_`?

查看:105
本文介绍了`forSome`的所有用法是否可以被等效的`_`替代?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如, List [T] forSome {type T} 相当于 List [_] ,但对于 forSome 的所有可能用法都适用,或者有些情况下 forSome 不能被等价的第二个语法?

For instance, List[T] forSome { type T } is equivalent to List[_], but is this true for every possible usage of forSome or are there cases where forSome cannot be replaced by an equivalent of the second syntax?

推荐答案

不,所有的用法都可以这样转换。像这样的东西(感谢 retronym ,下面,谁应该得到这个赞赏)

No, not all usages can be thus converted. Something like this (thanks to retronym, below, who should be getting the upvotes on this one)

def foo(xs: Map[T, T] forSome { type T})

是我可以在不止一个地方使用存在,但是它是相同的存在。显然,如果你使用通配符,你会指的是不同的存在

The point here is that I can use the existential in more than one place but it is the same existential. Obviously, if you used wildcards, you would be referring to different existentials

这篇关于`forSome`的所有用法是否可以被等效的`_`替代?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆