Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

2013-11-18から1日間の記事一覧

クラス中で「===」、「[]=」演算子の定義

class SS def []= a,b,c b + c end def === a a == 42 ? true : false end def + a 42 end end => nil > ss = SS.new => #<SS:0x007fed122ac7e8> > ss[0,1] = 2 => 2 > ss[0] = 1,2 ArgumentError: wrong number of arguments (2 for 3) > ss === 42 => true > ss === 9 => false </ss:0x007fed122ac7e8>…