views:

65

answers:

2

While coding in Ruby I did not really miss the type-orientedness of Java or C++ so far, but for some cases I think it is useful to have them. For Python there was a project PyProtocols which defined interfaces and protocols for objects. Does a similar initiative also exist for Ruby? I would like to be able to declare the expected parameters for some methods for some objects (for the entire code I find such think useless). It the method during the execution receives an unexpected input, it tries to adapt it or if it cannot, it throws an exception. Does something similar exist for Ruby? Introducing types for a type-less language like Ruby might sound freak, but I think types are sometimes useful. Thanks for help.

+1  A: 

Check project Ruby-Contract

Not more work is happening on it. :(

Webbisshh
The documentation seems to talk about interesting things for the first glance! With its adaption it might be similar to pyprotocols. Have you tried to work with it? Is it stable? I want to use to make parts of my code better fixed..
fifigyuri
just came across that project while i was learning Ruby, never used it! sorry :(
Webbisshh
+1  A: 

This might be interesting for the second part of your question: Type checking in ruby

Benno