[Ironruby-core] apparently only with extension methods nil != System::Object

Ivan Porto Carrero ivan at flanders.co.nz
Fri May 1 10:17:16 EDT 2009


I've done some more investigation and it appears that it has to do with
Extension methods.

public static bool IsNull(this object value)
{
return value == null;
}

and

public static bool IsNull2(object value)
{
return value == null;
}

>>> System::Web::Mvc::IronRuby::Extensions::ObjectExtensions.is_null nil
:0: can't convert NilClass into Object (TypeError)

>>> System::Web::Mvc::IronRuby::Extensions::ObjectExtensions.is_null2 nil
=> true

I've commented the issue on codeplex but couldn't change the title of the
bug.


---
Author of IronRuby in Action (http://manning.com/carrero)

Andy Warhol <http://www.brainyquote.com/quotes/authors/a/andy_warhol.html>
- "I am a deeply superficial person."

On Fri, May 1, 2009 at 10:15 AM, Ivan Porto Carrero <ivan at flanders.co.nz>wrote:

> Hi
> I had specs that used to work but now apparently they don't anymore.
> I'd expect that a nil from ruby maps to null in C# but this doesn't seem to
> be the case.
>
>
> I'm using the following code
>
>
>         public static bool IsNotNull(this object value)
>         {
>             return value != null;
>         }
>
>         public static bool IsNull(this object value)
>         {
>             return value == null;
>         }
>
> >>> ObjectExtensions.is_null(nil)
> :0: can't convert NilClass into Object (TypeError)
>
> I'd expect it to return true ;)
>
> ---
> Author of IronRuby in Action (http://manning.com/carrero)
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090501/e5f8bc5f/attachment.html>


More information about the Ironruby-core mailing list