DEV Community

Discussion on: Daily Challenge #75 - Set Alarm

Collapse
 
fennecdjay profile image
Jérémie Astor • Edited

in Gwion.
Using the newly implemented pattern matching ability.

fun int setalarm(const bool employed, const bool vacation) {
  match employed {
    case true: return !vacation;
    case _: return false;
  }
}

<<< setalarm(true, true) >>>;
<<< setalarm(false, true) >>>;
<<< setalarm(false, true) >>>;
<<< setalarm(true, false) >>>;

I should implement implicit casting from bool to int and vice-versa.


EDIT: done and working.

BONUS:

  • set ! operator as boolean, which hopefully makes more sense
  • demonstrate (very) bad git usage 😕