From 8ba3026e9cb1bc85fa8aa8e1f56b407948db9e52 Mon Sep 17 00:00:00 2001 From: Shachi Bista Date: Mon, 30 Apr 2018 01:01:42 +0200 Subject: [PATCH] Pin variables so that they are not rebound. All non-happy path cases fail otherwise. --- lib/door.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/door.ex b/lib/door.ex index 024bb88..70b3037 100644 --- a/lib/door.ex +++ b/lib/door.ex @@ -24,11 +24,11 @@ defmodule Door do def handle_event(:cast, {:press, digit}, :locked, {code, remaining, unlock_time}) do case remaining do - [digit] -> + [^digit] -> IO.puts "[#{digit}] Correct code. Unlocked for #{unlock_time}" {:next_state, :open, {code, code, unlock_time}, unlock_time} - [digit|rest] -> + [^digit|rest] -> IO.puts "[#{digit}] Correct digit but not yet complete." {:next_state, :locked, {code, rest, unlock_time}}