Array of Types in Ruby -


I am trying to create objects of various types of items and check validity. I need a lot of things so I can do something like this:

  tryclasses (in) type = [Foo :: A, Foo :: B, Foo :: C] types.each Do it Type | Return to A = Type.New (in)! = Null End End  

How do I create class types and create an array? By doing this, I am getting no motter (undefined method 'A' for Foo)

Apart from this There are clear syntax errors (such as in a search term, and zero spelling zero in Ruby), the code shown by you will work properly It is, and in fact it does when I copy and paste it into a Ruby installation. It assumes that the classes Foo :: A , Foo :: B and Foo :: C actually exist. If they do not, then this code obviously can not work.

This is completely non-Ruby and simply violates the coding convention in the book:

  1. Indentation 2 spaces
  2. Method names snake_case , not camelcase
  3. clearly zero is no-no, simply #nil ?
  4. try_classes does not really name an intentional disclosure method
  5. and in WTF / Code> mean?
  6. Ruby clearly prefers high-order methods over looping

    Here's more RubyShow version of code written by: < Pre> def can_create_object? (* Args) [Foo :: A, Foo :: B, Foo :: C]. Non? What? Class | Klass.new (* args) .nil? End of End

    However, note that I am quite sure that the whole idea is fundamentally flawed.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -