On 7 July 2010 17:18, Martin DeMello <martindemello / gmail.com> wrote:
> class User
>   >
>   >  >  
>
>   >   
>  
> end
>
> class Symbol
>   
>  >  
> end
>
> a = User.new
> a.banned = true
>
> case a
> when :banned? ; puts "banned!"
> when :active? ; puts "active!"
> end
>
> a.banned = false
>
> case a
> when :banned? ; puts "banned!"
> when :active? ; puts "active!"
> end
>
> martin
>

Quite cool the Symbol#===,
it made me think to Proc#===

Sadly, Proc need always a method to be created (so &:sym can not be
used directly)
But I found a (convoluted) example to use Proc#===

#encoding: utf-8
alias ::lambda

def check(user)
  case user
  when &:banned?)
    puts "Banned !"
  when &:active?)
    puts "This is over-convoluted, but you're fine!"
  end
end

user = User.new
user.banned = true
check user
user.banned = false
check user