From: Intransition Date: 2012-01-17T00:57:39+09:00 Subject: Re: The Better Code ------=_Part_3918_19038363.1326729456702 Content-Type: multipart/alternative; boundary="----=_Part_3919_2707214.1326729456702" ------=_Part_3919_2707214.1326729456702 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Some very interesting comments. It would appear that a certain contingent are for a middle way, something like: def self.assert(*args, &blk) opts = (Hash === args.last ? args.pop : {}) bt = opts[:backtrace] || caller msg = opts[:message] err = new(msg, *args, &blk) err.set_backtrace(bt) err.assert end I find myself doing that more often myself, but when I later revisit the code tend to expand it to long form. Yet, given some of the arguments, I wonder if using in-line comments along with the super-concise version would not be a good "middle" approach too: def self.assert(*a, &b) o = (Hash === a.last ? a.pop : {}) # options t = o[:backtrace] || caller # backtrace m = o[:message] # message e = new(m, *a, &b) # assay exception e.set_backtrace(t) e.assert end ------=_Part_3919_2707214.1326729456702 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Some very interesting comments. It would appear that a certain contingent a= re for a middle way, something like:

    def self.assert(*args, &blk)<= br style=3D"text-align: left; ">  &= nbsp;   opts =3D (Hash =3D=3D=3D args.last ? args.pop : {})

      bt  =3D opts[:backtrace] = || caller
      msg =3D opts[:message]

      err =3D new(msg, *args, &blk)
&nbs= p;     err.set_backtrace(bt)
      e= rr.assert
    end

I find myself doing that more often myself, but when I later revisit the= code tend to expand it to long form.

Yet, given some of the argument= s, I wonder if using in-line comments along with the super-concise version = would not be a good "middle" approach too:

    def sel= f.assert(*a, &b)
      o =3D (Hash =3D=3D=3D a= .last ? a.pop : {})  # options

    =   t =3D o[:backtrace] || caller  # backtrace
  &nb= sp;   m =3D o[:message]             &nbs= p;# message

      e =3D new(m, *a, = &b)           # assay exception
&nbs= p;     e.set_backtrace(t)
      e.assert=
    end


------=_Part_3919_2707214.1326729456702-- ------=_Part_3918_19038363.1326729456702--