DEV Community

Discussion on: What language features/concepts do insiders of the language love and outsiders hate?

Collapse
 
ben profile image
Ben Halpern

How do you feel about this:

If I write

[].count == 0

My linter will ask me to change it to

[].count.zero?
Thread Thread
 
evanoman profile image
Evan Oman

wat

Thread Thread
 
6temes profile image
Daniel • Edited

Actually, it your be more idiomatic to write:

[].empty?

I do love Ruby for those things. I can write business code in a way that is perfectly understandable the first time I read it.

Thread Thread
 
ben profile image
Ben Halpern

Yeah, this was a bad example

Thread Thread
 
databasesponge profile image
MetaDave πŸ‡ͺπŸ‡Ί

But I like #zero?, and have found situations where x == 0 was not "working" and x.zero? was. Don't ask me what it was though – I can barely remember yesterday – but maybe someone can explain that.