开发者

how to define a class in only one line?

开发者 https://www.devze.com 2023-01-04 08:23 出处:网络
I tried class X begin end and 开发者_JAVA百科 class X {} neight correct. What is the right code?You need a semicolon after class X:

I tried

class X begin end

and

开发者_JAVA百科
class X {}

neight correct. What is the right code?


You need a semicolon after class X:

class X; end


correct and verified example:

class C; end

and another, tricky solution :)

C = Class.new
0

精彩评论

暂无评论...
验证码 换一张
取 消