Can some show me how to implement this java program using Ruby?
I am simply trying to prevent the testclass from being instantiated in
I am then checking to see if the the class has instanatiated properly.
public testclass() throws Exception
testexception = new Exception(“Instantiation cancelled.”);
public class testprogram
public static void main(final String taArgv)
testclass mytest = null;
mytest = new testclass();
if (mytest == null)
System.out.println(“Instantiation not cancelled.”);
I am new to Ruby but this is what I have so far:
raise "Instantiation cancelled."
mytest = Testclass.new()
rescue Exception => e
puts e exit 1
puts “Instantiation not cancelled.”
If the raise line in the initialize method is disabled, the puts
“Instantiation not cancelled.” line does not execute.