Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #6620

Create instance of class. Class name stored in a string.

Newsgroups comp.lang.ruby
Date 2012-09-24 17:17 -0700
Message-ID <d97fb22b-73b0-4461-b21d-2dce663839ab@googlegroups.com> (permalink)
Subject Create instance of class. Class name stored in a string.
From shaw.cttk@gmail.com

Show all headers | View raw


Hi, I'm super new in Ruby World, and got in trouble with that:

how do I call the 'new' method of a class I don't know the name? The name of the class is stored in a string.

something like:

arg1 = "RADIUS"
codec = arg1.new

I would like to create an instance of whatever class name is stored in arg1 string.

Thanks in advance.

-- sfim

Back to comp.lang.ruby | Previous | NextNext in thread | Find similar


Thread

Create instance of class. Class name stored in a string. shaw.cttk@gmail.com - 2012-09-24 17:17 -0700
  Re: Create instance of class. Class name stored in a string. Robert Klemme <shortcutter@googlemail.com> - 2012-09-25 08:42 +0200

csiph-web