From: "Юрий Соколов" Date: 2012-03-11T05:14:33+09:00 Subject: [ruby-core:43164] Re: Help w/ some C to create NullClass --e89a8fb1ede03be0e004bae9288c Content-Type: text/plain; charset=ISO-8859-1 class Object; def self; self; end; end Null = Class.new{ def self; nil; end def present?; false; end def presence; nil; end def empty?; true; end def blank?; true; end def new; self; end def method_missing(*args); self; end }.new if Null.a.b.s.self # this will not be executed end if [].self # but this will end 2012/3/10 trans > I am trying to write a C extension for "NullClass" functionality. I've > again arrived at a usecase where I could really use it, so I've endeavored > to finally code it. However, my C is almost as bad as my Japanese ;-) I've > tried to work out the code just by comparison to how NilClass is defined, > but so far no luck. Here is the repo: https://github.com/rubyworks/null. > If anyone here could take a look and offer some direction, I would be very > grateful. > > Thanks > > --e89a8fb1ede03be0e004bae9288c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
class Object; def self; self; end; end
= Null =3D Class.new{
=A0 def self; nil; end
=A0 def present?; false; end
=A0 def presence; nil; en= d
=A0 def empty?; true; end
=A0 def blank?; true; end=
=A0 def new; self; end
=A0 def method_missing(*a= rgs); self; end
}.new

if Null.a.b.s.self=
=A0 # this will not be executed
end
if [].self
=A0 # but this will<= br style=3D"font-family:courier new,monospace"> end

<= div class=3D"gmail_quote">2012/3/10 trans <transfire@gmail.com>
I am trying to write a C extension for "NullClass" functiona= lity. I've again arrived at a usecase where I could really use it, so I= 've endeavored to finally code it. However, my C is almost as bad as my= Japanese ;-) I've tried to work out the code just by comparison to how= NilClass is defined, but so far no luck. Here is the repo:=A0https://github.com/rubyw= orks/null. If anyone here could take a look and offer some direction, I= would be very grateful.

Thanks


--e89a8fb1ede03be0e004bae9288c--