[erlang-questions] nand problem
Mon Jan 26 18:46:57 CET 2015
On Mon, Jan 26, 2015 at 06:36:57PM +0100, Roelof Wobben wrote:
> Hugo Mills schreef op 26-1-2015 om 18:26:
> >On Mon, Jan 26, 2015 at 05:21:42PM +0100, Roelof Wobben wrote:
> >>b_and(true, true) ->
> >> true;
> >>b_and(true, false) ->
> >> false;
> >>b_and(false, true) ->
> >> false;
> >>b_and(false, false) ->
> >> false.
> > You could make this shorter and possibly easier to read with
> >b_and(true, true) ->
> > true;
> >b_and(_, _) ->
> > false.
> > i.e. define the (one) special case, and then just say that
> >everything else evaluates to false. You can do something similar with
> > Hugo.
> Yes, I could do that .
> I thought I have read somewhere that using _ for defensive
> programming was nog good practice
> but that was on using other on case on the next chapter.
I'd argue that this isn't defensive programming at all. It's just
stating the behaviour of your function in the most concise form. "If
both parameters are true, return true, otherwise return false."
> I will change my code.
> erlang-questions mailing list
Hugo Mills | Two things came out of Berkeley in the 1960s: LSD
hugo@REDACTED carfax.org.uk | and Unix. This is not a coincidence.
PGP: 65E74AC0 |
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 836 bytes
Desc: Digital signature
More information about the erlang-questions