Skip to content

Instantly share code, notes, and snippets.

@mattpodwysocki
Created July 19, 2010 22:18
Show Gist options
  • Save mattpodwysocki/482133 to your computer and use it in GitHub Desktop.
Save mattpodwysocki/482133 to your computer and use it in GitHub Desktop.
load_assembly 'System.Core'
load_assembly 'System.CoreEx, Version=1.0.2521.104, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
load_assembly 'System.Reactive, Version=1.0.2521.104, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
using_clr_extensions System
using_clr_extensions System::Linq
include System
include System::Linq
class Object
def to_seq(type = Object)
System::Linq::Enumerable.method(:of_type).of(type).call(self.to_a)
end
end
range = (1..10).to_seq
observable =
Observable.to_observable(range).where(lambda {|next_val| next_val % 2 == 0})
dispoable = observable.subscribe(Action[Object].new {|val| puts "Next value: #{val}" })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment