Roelof Wobben <[email protected]> writes:
> So if I understand everything well when I want true or false I do not
> need a if.
No, when the last form of your function already returns true or false,
e.g., (< 12 age 20), then you don't need to wrap that in an `if` which
checks if the result is true to return true, or return false otherwise.
I mean, in a Java/C/Pascal/whatever-like language, you also wouldn't
write
boolean teen(age) {
if (age > 12 && age < 20) {
return true;
} else {
return false;
}
}
but simply
boolean teen(age) {
return age > 12 && age < 20;
}
because the <, >, and && operators already result in booleans, right?
> In all other cases I need a if.
You always need an `if` if the value you want to return is not identical
with the value of the test expression.
> Regarding the ; I thought I was a divider between the then and the
> else
Lisps have no need for syntactical irregularities like that.
Bye,
Tassilo
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.