How about making the return value an array of the captured strings, or nil 
if there was no match? 

Also, I suppose it should be a compile error if the regexp on the left hand 
side does not contain any named captures.  Otherwise, = becomes a variant of 
=~. 

   David 


Tanaka Akira writes: 

> In article <476A087E.3070000 / davidflanagan.com>,
>   David Flanagan <david / davidflanagan.com> writes: 
> 
>>    /(?<firstchar>.)(?<secondchar>.)/ = 'foo'
>>    firstchar   # => 'f'
>>    secondchar  # => 'o'
> 
> I think it is possible idea. 
> 
> However I see an issue about the value of the assignment. 
> 
> In Ruby, an assignment expression returns the value of right
> hand side expression consistently.  But if the return value
> of "regexp-based destructuring assignment" is the right hand
> side string, the value is useless to check the pattern is
> matched or not.  If the assignment returns some value to
> check the match, it breaks the consistency.
> -- 
> Tanaka Akira 
>