it’s rarely important to know. Gen stands for “general” — meaning it might or might not be a parallel collection. TraversableOnce means it might (or might not) be e.g. an Iterator which is consumed in a single pass.
it basically says that it's a data strucutre which can be traversed at least once, and Gen means it has no idea whether it happens sequantially or in parallel
Anyone have a recommendation for lightweight communication from scala to lua (for an API)? Tcp and cURL are the best options I've found so far.
HTTP is usually quite well supported
Hi. I am a newly with Scala and actually reading Scala 2nd Edition and got a question on how to create an empty list. I read that Nil is a shorter way to create an empty... Why Nil? Just by its name, I would never know that Nil does that? What the explanation for Nil?
because Nil means empty list
Nil is the empty list. The one and only.
So it doesn't "create" anything; it's just a value.
Thanks for you quick answer but I'll orient my question differently
Traditionally nil was the empty list in Lisp, so that's almost certainly where the name came from.
Nil, in some languages like Objective-C means the same thing as null in Java
To me, there is no obvious relation between Nil and an empty list...
They could have used "Lon".. at it would be a acroymn for "List of Nothing"....
I think the convention comes from Lisp, but I'm not 100% sure.
In FP the linked list constructors are almost always called cons and nil.
@agilisticdev there are a lot of new terms to learn when you start learning functional programming
I think that this course is a very good starting point for learning functional programming and scala
Thanks for your quick answer. I do not find :: and Nil very readable and easy to understand but as you guys said, these terms are used in FP, so I'll get used to it
get used to it, and it's very readable vs alternatives
Justin du Coeur, AKA Mark Waks
@agilisticdev This usage of nil is 50+ years old in the functional-programming community. It's a bit unfortunate that Objective-C used it to mean something else, but it has meant "empty list" since the early days of software -- it not only predates Objective-C, I believe it predates C...
correct. lisp was invented in the late 1950's
what happened with Coursera’s progfun course this year, it was supposed to happen in September no?
is Either idiomatic to use? I am looking for a good way of error handling in the standard library
Either is what's provided in stdlib but it is awkward to use because it is unbiased. scalaz.\/ and cats.Xor are better. Scalactic Or as well.
@shimberger here is a good overview of some possibilities and their trade-offs.
Is this ok to signal application exceptions through failed futures (methods returning Future[A]) or is this only for unexpected errors? Should my methods return Future[A] or Future[Try[A]] when I expect some errors?
It was pretty clear to me that Future[A] is enough but I think I read somewhere (can't find the source now) that it's wrong
exceptions always model unexpected failures, therefore if you want to throw an exception Future[A] is ok. If you want to explicitly let users handle the error case, then you should use Future[Try[A]].
Which one is better depends on the use case and needs to be decided wisely ;)