def has_key?(key) : Returns true when key given by key exists, otherwise false.
Signed-off-by: Ren Wen 15991987063@163.com --- src/lib/job.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/lib/job.cr b/src/lib/job.cr index 2418c82..e3d47de 100644 --- a/src/lib/job.cr +++ b/src/lib/job.cr @@ -289,7 +289,7 @@ class Job "SCHED_PORT"]
initialized_keys.each do |key| - if @hash.has_key?(key) == false + unless @hash.has_key?(key) return false end end
On Thu, Nov 12, 2020 at 04:17:23PM +0800, Ren Wen wrote:
def has_key?(key) : Returns true when key given by key exists, otherwise false.
Signed-off-by: Ren Wen 15991987063@163.com
src/lib/job.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/lib/job.cr b/src/lib/job.cr index 2418c82..e3d47de 100644 --- a/src/lib/job.cr +++ b/src/lib/job.cr @@ -289,7 +289,7 @@ class Job "SCHED_PORT"]
initialized_keys.each do |key|
if @hash.has_key?(key) == false
unless @hash.has_key?(key) return false end
You can just use
return false unless @hash.has_key?(key)
Thanks, Yuanchao
end
-- 2.23.0
On Thu, Nov 12, 2020 at 04:38:53PM +0800, Li Yuanchao wrote:
On Thu, Nov 12, 2020 at 04:17:23PM +0800, Ren Wen wrote:
def has_key?(key) : Returns true when key given by key exists, otherwise false.
Signed-off-by: Ren Wen 15991987063@163.com
src/lib/job.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/lib/job.cr b/src/lib/job.cr index 2418c82..e3d47de 100644 --- a/src/lib/job.cr +++ b/src/lib/job.cr @@ -289,7 +289,7 @@ class Job "SCHED_PORT"]
initialized_keys.each do |key|
if @hash.has_key?(key) == false
unless @hash.has_key?(key) return false end
You can just use
return false unless @hash.has_key?(key)
Only simplify logic not code. The former is complex.
Thanks, RenWen
Thanks, Yuanchao
end
-- 2.23.0
On Thu, Nov 12, 2020 at 04:38:53PM +0800, Li Yuanchao wrote:
On Thu, Nov 12, 2020 at 04:17:23PM +0800, Ren Wen wrote:
def has_key?(key) : Returns true when key given by key exists, otherwise false.
Signed-off-by: Ren Wen 15991987063@163.com
src/lib/job.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/lib/job.cr b/src/lib/job.cr index 2418c82..e3d47de 100644 --- a/src/lib/job.cr +++ b/src/lib/job.cr @@ -289,7 +289,7 @@ class Job "SCHED_PORT"]
initialized_keys.each do |key|
if @hash.has_key?(key) == false
unless @hash.has_key?(key) return false end
You can just use
return false unless @hash.has_key?(key)
Got it. I have modified.
Thanks, RenWen
Thanks, Yuanchao
end
-- 2.23.0