What is the primary difference in these two code snippets?

Technology CommunityCategory: RubyWhat is the primary difference in these two code snippets?
VietMX Staff asked 3 years ago
Problem
// Java
public boolean isEmpty(String s) {
  return s.length() == 0;
}
# ruby
def empty?(s)
  return s.size == 0
end
  • The Java method only accepts Strings as arguments and only returns a boolean while…
  • The ruby method accepts any Object and could return anything, but in this case will return a boolean if executed without exceptions.