nskins / goby

Command-line role-playing game framework
MIT License
122 stars 56 forks source link

Switch sentinel value from -1 to nil #69

Closed nskins closed 7 years ago

nskins commented 7 years ago

Certain functions return -1 to indicate that no matching value is found. Examples: has_item and has_battle_command in lib/Entity/entity.rb. We should change it so that it returns nil instead of -1. This will result in cleaner code since we can change the following:

index = has_item(Item.new)
if (index != -1)
  # ...
end

to this:

index = has_item(Item.new)
if (index)
  # ...
end