3 ms·
So you basically put type information in the names. That's typing in a sense.
by ww520 14y ago
So you basically put type information in the names. That's typing in a sense.
- trustfundbaby 14y agoI see where you're going but thats not really what we're doing with that ... @user.posts actually returns an array of posts and @user.posts.first returns an actual Post object. You could also change @user.posts to be @user.contributions, for example, and that would hide the fact that contributions was just an array of Post objects.
- lloeki 14y agoNo, he puts typing in the interface, and that's indeed typing in a sense, called duck-typing.
- ww520 14y agoI think we are talking about different things. Duck-typing doesn't help in depicting what the return type of a function is when looking at the function signature only. You need to look at the function implementation (the actual duck) to tell what the return type is.
- phamilton 14y agoMy point I guess was that with proper abstractions and duck typing you really don't have to care about the type. I only notice something isn't a duck when I try to use it like a duck and it fails - which is surprisingly infrequent.
- ww520 14y agoIt becomes difficult to tell it's a duck when reading code, which was the original complaint. Duck type works when you actually try calling it.