On 9/28/06, MonkeeSage <MonkeeSage / gmail.com> wrote:
> There seem to be two kinds of predicates -- those which ask about what
> an object is like, and those which ask about what it is; e.g:
>
> obj.respond_to? :m # does obj respond to :m?
> obj.include? item  # does obj include item?
> obj.all? { cond }  # do all members of obj meet cond?
>
> obj.is_a? Class        # is obj a Class?
> obj.instance_of? Class # is obj an instance of Class?
> obj.nil?               # is obj nil?
>
> #start_with? seems to fit into the first category, and to be consistant
> with the grammar of that category:
>
> obj.start_with? 'string' # does obj start with 'string'?

Not that it's going to change, and it's all water long under the bridge, but....

Those predicates are usually part of a larger expression.

We wouldn't say

Give me my nine-iron, if does my bag have my nine-iron.

In situ which of these sounds better to the English speaker?

do_something if a.start_with?('foo')
do_something if a.respond_to?(:fred)
do_something if a.include?(:joe)

or

do_something if a.starts_with?('foo')
do_something if a.responds_to?(:fred)
do_something if a.includes?(:joe)

Try it with other statements and modifiers like unless, while, until etc.

-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/