From: shevegen@... Date: 2016-02-19T23:10:14+00:00 Subject: [ruby-core:73900] [Ruby trunk Feature#12075] some container#nonempty? Issue #12075 has been updated by Robert A. Heiler. Perhaps the name .contains? might be good? Although, .include? sort of is more or less synonymous with .contains? so perhaps this is not a good choice either. .nonempty? seems a bit long, .non_empty? would be even longer :) .empty? is a very good name already, I am not sure if "! .empty?" has a good name, though ruby uses the keyword "not" already. Could use .notempty? haha sorry, I have no good suggestion for a fitting name for negation either, but I am totally fine with the idea and functionality of the proposal itself, it's a good one. ---------------------------------------- Feature #12075: some container#nonempty? https://bugs.ruby-lang.org/issues/12075#change-57061 * Author: Yui NARUSE * Status: Assigned * Priority: Normal * Assignee: Yukihiro Matsumoto ---------------------------------------- I sometimes write following code. ``` ary = some_metho_returns_nil_or_empty_container() # nil or "" or [] or {} if ary && !ary.empty? # some code end ``` But the condition `ary && !ary.empty?` is too long and complex. Though Ruby 2.3 introduces `&.`, but this can���t be written as `ary&.empty?`. One idea is add `nonempty?` write as `ary&.nonempty?`. akr: `nonempty?` is not good name because human is not good at handling This discussion matches following core classes: * String * Array * Hash -- https://bugs.ruby-lang.org/ Unsubscribe: