for {
...
(a,b) = foo
} yield ()
var
inside traits desugar into private fields with a setter method
StringPlusAny
StringPlusAny
, and that's not it
toString
.
StringPlusAny
feels confusing for newcomers - it's another of these failures where the root cause is hidden
+ foo +
instead of + foo.toString +
? It seems like that would be a simplification that could prevent diverging semantics – i.e., it means that interpolation and concatenation both have the same conversion semantics, rather that having interpolation do its own string conversion, which could get out of sync with that for concatenation. Since both are currently defined to use .toString
, it wouldn’t change behavior, but could change how it’s seen by WartRemover.
@som-snytt @nrinaudo string interpolator converts to string + now.
If you didn't like string interpolation before, you won't ike string_+ either. It's all stringifications.
Warts.AllBut(Any, Nothing)
– but I guess most people probably want something more fine-grained than that 😆
Warts.andAll
.
Warts.andAll
, your code still passes the build even if it's really ugly.
def doStuff(x: Thing) = { x.doThing(); list.add(x) }
so that list
holds the Things
I have operated on. How would I write that with Warts.unsafe
?
I had code that did
if (list.isEmpty) {
stuff(list.head, list.tail)
} else {
otherStuff()
}
Warts.TraversibleOpts told me to use headOption instead. Warts.OptionPartial won't like
list.headOption.ifPresent(stuff(_, list.tail)).orElse(() => otherStuff()).get
but I don't see another way to do it. getOrElse(otherStuff())
is wrong, because calling otherStuff is wrong if the list is not empty.
I suspect the problem is that Option
should have a getOrElse
that takes a function to build the result, not just getOrElse(T)
. Is there another way to do this?
=>T
and not T
, so the parameter will not be evaluated in the nonEmpty case