TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Scala’s Types of Types

120 pointsby ddispaltroabout 9 years ago

4 comments

greydiusabout 9 years ago
&gt; A major difference from Java in Scala is, that container types are not-variant by default!<p>Only arrays are variant &quot;by default&quot; in java (which was a huge mistake). Variance for generic collections is specified at use, not at the type definition level.<p>&gt; This means that if you have a container defined as Box[A], and then use it with a Fruit in place of the type parameter A, you will not be able to insert an Apple (which IS-A Fruit) into it.<p>No. What this really means is that you can&#x27;t assign an instance of Box[Apple] to a val&#x2F;var of type Box[Fruit].
评论 #11292676 未加载
igraviousabout 9 years ago
The following has always had me a bit puzzled, be interested in responses.<p>If bottom type corresponds to no(thing) and top to any(thing) where does every(thing) and some(thing) fit in? Is there any semantic distinction between any(thing) and every(thing)? There should be, right? For me, some(thing) that had type any(thing) would be an _individual_ but some(thing) that had type every(thing) {actually the mind boggles a bit here} would be a _colection_, the collection of all existing or living things. In fact Ruby has the notion of Objectspace. So we can say things like ObjectSpace.each_object{|x| p x}
评论 #11290849 未加载
评论 #11290870 未加载
评论 #11293868 未加载
评论 #11292674 未加载
junkeabout 9 years ago
&gt; if (false) 23 else null<p>Why isn&#x27;t the type of this expression Null?
评论 #11290994 未加载
评论 #11292781 未加载
catnaroekabout 9 years ago
Calling those “types of types” is highly misleading. The term “type of types” has a very precise technical meaning: <a href="https:&#x2F;&#x2F;ncatlab.org&#x2F;nlab&#x2F;show&#x2F;type+of+types" rel="nofollow">https:&#x2F;&#x2F;ncatlab.org&#x2F;nlab&#x2F;show&#x2F;type+of+types</a>
评论 #11293516 未加载
评论 #11291856 未加载