Skip to content

Commit

Permalink
Add workaround in lambda function for opal
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborbata committed Mar 24, 2021
1 parent 4ec987c commit c1f8446
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 119 deletions.
11 changes: 7 additions & 4 deletions bin/todo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,13 @@ def add_note(item, text)

def delete_note(item, num = nil)
update_task(item, :show, lambda do |task|
return task.delete(:note) if num.to_s.empty?
raise "#{num.to_i}: Note does not exist" if num.to_i <= 0 || task[:note].to_a.size < num.to_i
task[:note].delete_at(num.to_i - 1)
task.delete(:note) if task[:note].empty?
if num.to_s.empty?
task.delete(:note)
else
raise "#{num.to_i}: Note does not exist" if num.to_i <= 0 || task[:note].to_a.size < num.to_i
task[:note].delete_at(num.to_i - 1)
task.delete(:note) if task[:note].empty?
end
end)
end

Expand Down
16 changes: 8 additions & 8 deletions node/todo.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions node/todo.js.rb
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,13 @@ def add_note(item, text)

def delete_note(item, num = nil)
update_task(item, :show, lambda do |task|
return task.delete(:note) if num.to_s.empty?
raise "#{num.to_i}: Note does not exist" if num.to_i <= 0 || task[:note].to_a.size < num.to_i
task[:note].delete_at(num.to_i - 1)
task.delete(:note) if task[:note].empty?
if num.to_s.empty?
task.delete(:note)
else
raise "#{num.to_i}: Note does not exist" if num.to_i <= 0 || task[:note].to_a.size < num.to_i
task[:note].delete_at(num.to_i - 1)
task.delete(:note) if task[:note].empty?
end
end)
end

Expand Down
Loading

0 comments on commit c1f8446

Please sign in to comment.