From 7fa77c350b903aa36f105a985abe4992da44f016 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Tue, 31 Oct 2023 18:45:47 +0000 Subject: [PATCH] Refactor: Inline Variable. --- lib/map.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/map.rb b/lib/map.rb index f2dec75f..6fd2cd26 100644 --- a/lib/map.rb +++ b/lib/map.rb @@ -7,8 +7,7 @@ def initialize(x_domain:, y_domain:, obstacles: []) def next_location_forwards(location:) case location.direction when 'N' - new_location = location.forwards - corrected_for_north_pole(new_location) + corrected_for_north_pole(location.forwards) when 'E' next_x = at_right_hand_edge?(location.coordinates) ? @x_domain.begin : location.coordinates.x + 1 Location.new( @@ -16,8 +15,7 @@ def next_location_forwards(location:) direction: location.direction ) when 'S' - new_location = location.forwards - corrected_for_south_pole(new_location) + corrected_for_south_pole(location.forwards) when 'W' next_x = at_left_hand_edge?(location.coordinates) ? @x_domain.end : location.coordinates.x - 1 Location.new(