Skip to content

Commit

Permalink
'otherwise' method returns immediately the result
Browse files Browse the repository at this point in the history
  • Loading branch information
elucash committed Feb 5, 2018
1 parent 94206f0 commit 9c1cfc1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion experiments.im
Expand Up @@ -554,7 +554,7 @@ fn futionale(robbie Name, williams Lastname) Name {

winners = a ?? "oscilli"

[a * z for a <- b, z <- c]
[for a <- b, z <- c {a * z}]

a*.{ e -> e.empty }

Expand Down
9 changes: 5 additions & 4 deletions src/io/immutables/collect/Vect.java
Expand Up @@ -447,18 +447,19 @@ public When<R> head(BiFunction<E, Vect<E>, R> onHead) {
}

@CheckReturnValue
public When<R> otherwise(Function<Vect<E>, R> onElse) {
public R otherwise(Function<Vect<E>, R> onElse) {
if (result == null) {
result = requireNonNull(onElse.apply(Vect.this));
}
return this;
return result;
}

public When<R> otherwise(R r) {
@CheckReturnValue
public R otherwise(R r) {
if (result == null) {
result = requireNonNull(r);
}
return this;
return result;
}

@Override
Expand Down
3 changes: 1 addition & 2 deletions src/io/immutables/grammar/processor/Production.java
Expand Up @@ -337,8 +337,7 @@ Vect<Identifier> asIfChoiceReferences(Vect<Alternative> alternatives) {
a -> a.parts()
.<Boolean>when()
.single(this::subtypingReference)
.otherwise(false)
.get();
.otherwise(false);

if (alternatives.all(hasSingleReference)) {
return alternatives.map(
Expand Down

0 comments on commit 9c1cfc1

Please sign in to comment.