Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

    if warrior.feel.empty?
      warrior.walk! :forward
    else
      warrior.attack!
    end
Edit: if you're new to ruby syntax, then it's probably worth pointing out that the ? and ! on the end of the method names has no special function (they're both valid characters for using in method names). By convention, methods that return a boolean end in ? and methods that modify the object end in !. For example, Array has two sort methods - sort and sort!. some_array.sort will return a sorted copy of some_array but leave the original unsorted. some_array.sort!, however, will sort aome_array


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: