From: Chad Perrin Date: 2011-03-26T04:30:06+09:00 Subject: Re: shortcut for add unless nil ? --IJpNTDwzlM2Ie8A6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Mar 26, 2011 at 12:42:25AM +0900, Iain Barnett wrote: >=20 > Is there a way to define infix operators in Ruby, as I quite like this on= e? :) Actually, methods are kinda like infix operators anyway. One argument is followed by the method name, which is followed by any other argument(s): irb(main):001:0> 4.div 2 =3D> 2 The div method fits between the operands, when viewed as an operator. In fact, that's how other infix operators work: irb(main):002:0> 4./ 2 =3D> 2 I don't know of any way to eliminate the requirement for the dot used with methods you define, the way built-in operators do, though. --=20 Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] --IJpNTDwzlM2Ie8A6 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAk2M6ecACgkQ9mn/Pj01uKWGwwCggNgjzOlWovJZthJ+p6YZnqsI eCYAnil1wUsZiqjSnpJt2jIk7VuxQBGi =Z7Og -----END PGP SIGNATURE----- --IJpNTDwzlM2Ie8A6--