如果X不等于Y或Z则为红宝石

Lui*_*igi 1 ruby

我有以下内容:

a_disposition = [nil,'test','demo']

a_volume = a_disposition.count{|x| x != nil}
Run Code Online (Sandbox Code Playgroud)

我想要计算所有非NOT nil和NOT的值'test'.什么是红宝石的说法count where x is not nil and x is not 'test'?我正在使用ruby 2.0.

Mat*_*att 6

(a_disposition-[nil,'test']).count # => 1
Run Code Online (Sandbox Code Playgroud)