{"comment":{"url":"https://api.github.com/repos/evertr/warcraftIII/comments/12431642","html_url":"https://github.com/evertr/warcraftIII/commit/91b519724e41254b7a45cb6565bdcf3b63d01a47#commitcomment-12431642","id":12431642,"user":{"login":"monicao","id":165790,"avatar_url":"https://avatars.githubusercontent.com/u/165790?v=3","gravatar_id":"","url":"https://api.github.com/users/monicao","html_url":"https://github.com/monicao","followers_url":"https://api.github.com/users/monicao/followers","following_url":"https://api.github.com/users/monicao/following{/other_user}","gists_url":"https://api.github.com/users/monicao/gists{/gist_id}","starred_url":"https://api.github.com/users/monicao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monicao/subscriptions","organizations_url":"https://api.github.com/users/monicao/orgs","repos_url":"https://api.github.com/users/monicao/repos","events_url":"https://api.github.com/users/monicao/events{/privacy}","received_events_url":"https://api.github.com/users/monicao/received_events","type":"User","site_admin":false},"position":5,"line":10,"path":"lib/unit.rb","commit_id":"91b519724e41254b7a45cb6565bdcf3b63d01a47","created_at":"2015-07-29T21:35:55Z","updated_at":"2015-07-29T21:35:55Z","body":"This code works, but I think the readability could be improved. The nested if statement throws me off. Here's a suggestion:\r\n\r\n```ruby\r\ndef attack! (enemy)\r\n  if !self.dead? && !enemy.dead?\r\n    enemy.damage(self.attack_power)\r\n  else\r\n    false\r\n  end\r\nend\r\n```\r\n\r\nAlso do we really want this method to return false if the attack fails? If it is ok to have this method return nil (which is a falsey value anyway), we could shorten this to:\r\n\r\n```ruby\r\ndef attack! (enemy)\r\n  if !self.dead? && !enemy.dead?\r\n    enemy.damage(self.attack_power)\r\n  end\r\nend\r\n```\r\n"}}