I know these sound like pretty basic questions.. but I'm playing devil's advocate here (maybe rubyist advocate is better suited) and I imagine I will need a good chunk in a chapter somewhere to explain this stuff really clearly.
--- Met vriendelijke groeten - Best regards - Salutations Ivan Porto Carrero Blog: http://flanders.co.nz Twitter: http://twitter.com/casualjim Author of IronRuby in Action (http://manning.com/carrero) On Wed, May 13, 2009 at 5:57 PM, Ivan Porto Carrero <[email protected]>wrote: > Hi > I got into a discussion with Roy Osherhove about overriding statics. > > I know in C# it can't be done obviously and as long as I stay in Ruby you > can. I understand this may seem like straight-forward stuff. Can you give me > a pointer where I can take stock of what I can and can't do to CLR objects > and in which cases ruby things apply? > > But when you go back and call it from a C# class it takes the CLR > implementation > > public class MyClassWithAStatic{ > > public string HelloWorld(){ > return "Hello World!"; > } > > public static string GoodByeWorld(){ > return "Goodbye world!"; > } > } > > public class StaticCaller{ > > public string CallsStatic(){ > return MyClassWithAStatic.GoodByeWorld(); > } > } > > console session: > (master) » ir > IronRuby 0.4.0.0 on .NET 2.0.50727.4918 > Copyright (c) Microsoft Corporation. All rights reserved. > > >>> require 'spec/bin/ClrModels.dll' > => true > >>> include ClrModels > => Object > >>> MyClassWithAStatic > => ClrModels::MyClassWithAStatic > >>> MyClassWithAStatic.good_bye_world > => 'Goodbye world!' > >>> sc = StaticCaller.new > => ClrModels.StaticCaller > >>> sc.calls_static > => 'Goodbye world!' > >>> class MyClassWithAStatic > ... def self.good_bye_world > ... "From Ruby we say goodbye to you" > ... end > ... end > => nil > >>> MyClassWithAStatic.good_bye_world > => "From Ruby we say goodbye to you" > >>> sc = StaticCaller.new > => ClrModels.StaticCaller > >>> sc.calls_static > => 'Goodbye world!' > > New session to figure out if something could be done before the type was > actually created > > + C:\dev\caricature > (master) » ir > IronRuby 0.4.0.0 on .NET 2.0.50727.4918 > Copyright (c) Microsoft Corporation. All rights reserved. > > >>> require 'spec/bin/ClrModels.dll' > => true > >>> class MyClassWithAStatic > ... def self.good_bye_world > ... "From Ruby we say goodbye to you" > ... end > ... end > => nil > >>> ClrModels::StaticCaller.new.calls_static > => 'Goodbye world!' > > --- > Met vriendelijke groeten - Best regards - Salutations > Ivan Porto Carrero > Blog: http://flanders.co.nz > Twitter: http://twitter.com/casualjim > Author of IronRuby in Action (http://manning.com/carrero) > > Don Marquis <http://www.brainyquote.com/quotes/authors/d/don_marquis.html> - > "Procrastination is the art of keeping up with yesterday." >
_______________________________________________ Ironruby-core mailing list [email protected] http://rubyforge.org/mailman/listinfo/ironruby-core
