Freewind
Freewind

Reputation: 198408

how to define a class in only one line?

I tried

class X begin end

and

class X {}

neight correct. What is the right code?

Upvotes: 22

Views: 11517

Answers (2)

zed_0xff
zed_0xff

Reputation: 33257

correct and verified example:

class C; end

and another, tricky solution :)

C = Class.new

Upvotes: 27

Pär Wieslander
Pär Wieslander

Reputation: 28934

You need a semicolon after class X:

class X; end

Upvotes: 33

Related Questions