From: Colin Scott Date: 2012-01-02T10:21:46+09:00 Subject: [ruby-core:41867] [Feature patch] Set#to_ary to play well with Arrays --001517510be0a9a5c304b58167f1 Content-Type: multipart/alternative; boundary=001517510be0a9a5ba04b58167ef --001517510be0a9a5ba04b58167ef Content-Type: text/plain; charset=ISO-8859-1 2012-12-01 Colin Scott * lib/set.rb (to_a): make to_ary an alias Sets don't play very well with arrays. For example: irb(main):001:0> require 'set' => true irb(main):002:0> s = Set.new => # irb(main):003:0> a = [] => [] irb(main):004:0> s | a => # irb(main):005:0> a | s *TypeError: can't convert Set into Array* Set#to_a is already defined. By aliasing Set#to_ary to Set#to_a, the type conversion works. This should not change the behavior of Sets otherwise. --001517510be0a9a5ba04b58167ef Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
2012-12-01 Colin Scott <cs@cs.berkeley.edu>
* lib/set.rb (to_a): make to_ary an alias

Sets = don't play very well with arrays. For example:

irb(main):001:0> require 'set'
=3D> true
irb(main):002:0> s =3D Set.new
=3D>= ; #<Set: {}>
irb(main):003:0> a =3D []
=3D>= []
irb(main):004:0> s | a
=3D> #<Set: {}>
irb(main):005:0> a | s
TypeError: can't convert Set in= to Array

Set#to_a is already defined. By= aliasing Set#to_ary to Set#to_a, the type conversion works. This should no= t change the behavior of Sets otherwise.

--001517510be0a9a5ba04b58167ef-- --001517510be0a9a5c304b58167f1 Content-Type: application/octet-stream; name="ruby-changes.patch" Content-Disposition: attachment; filename="ruby-changes.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gwwszstu0 SW5kZXg6IGxpYi9zZXQucmIKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gbGliL3NldC5yYgkocmV2aXNpb24gMzQx NjcpCisrKyBsaWIvc2V0LnJiCSh3b3JraW5nIGNvcHkpCkBAIC0xNDUsNiArMTQ1LDkgQEAKICAg ICBAaGFzaC5rZXlzCiAgIGVuZAogCisgICMgQWxpYXMgb2YgdG9fYQorICBhbGlhcyA6dG9fYXJ5 IDp0b19hCisKICAgZGVmIGZsYXR0ZW5fbWVyZ2Uoc2V0LCBzZWVuID0gU2V0Lm5ldykgIyA6bm9k b2M6CiAgICAgc2V0LmVhY2ggeyB8ZXwKICAgICAgIGlmIGUuaXNfYT8oU2V0KQo= --001517510be0a9a5c304b58167f1--