IronRuby System.DateTime NilClass

Posted by Sergey Mirvoda on Stack Overflow See other posts from Stack Overflow or by Sergey Mirvoda
Published on 2010-02-11T09:21:54Z Indexed on 2010/04/07 21:13 UTC
Read the original article Hit count: 427

Filed under:
|
|

Why comparing to null is so unstable?

Just code.

IronRuby 0.9.4.0 on .NET 2.0.50727.4927
Copyright (c) Microsoft Corporation. All rights reserved.

>>> require 'System'
=> true
>>> i = System::Int32.MinValue
=> -2147483648
>>> i==nil
=> false
>>> d = System::DateTime.Now
=> 11.02.2010 14:15:02
>>> d==nil
(ir):1: can't convert NilClass into System::DateTime (TypeError)
>>> 

In 9.1 this code works as expected.

EDIT:

workaround:

>>> i.nil?
=> false
>>> d.nil?
=> false
>>> nil
=> nil
>>> nil.nil?
=> true
>>>

© Stack Overflow or respective owner

Related posts about .NET

Related posts about ironruby