Can anybody explain why DateTime in IronRuby is Object[]
sample code
IronRuby 0.9.1.0 on .NET 2.0.50727.4927
Copyright (c) Microsoft Corporation. All rights reserved.
>>> require 'System'
=> true
>>> t = System::DateTime.Now
=> Thu Dec 03 15:32:42 +05:00 2009
>>> t.is_a?(Time)
=> true
>>> t.is_a?(System::DateTime)
=> true
>>> t.is_a?(System::Object)
=> true
>>> t.is_a?(System::Object[])
=> true
>>> t.is_a?(System::Decimal)
=> false
Using
[]for generic types is a justifiable syntax for Ruby, but the current behavior you see (using[]on a non-generic type) is a open bug: http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=3355In Ruby, square brackets are only used for indexing into an array, not define a type-array … as there is no need for defining the type of a Ruby array. Ruby allows overloading whatever
[]means against any object, and Ruby’sClassobject doesn’t have a meaning for[], so we’ve defined[]to mean getting a generic type. Keep in mind that theofmethod is the preferred method to use;[]is really only there for convenience and similar syntax with IronPython.