我尝试了以下方法,但收到错误“参数数量错误(2 代表 0)”:
class Rating
NOOB = Rating.new(1, "U A NOOB")
def initialize(rating, message)
@rating = rating
@message = message
end
end
什么相当于用 Ruby 编写以下代码?(这是我做枚举的方式)
public class Rating {
public static Rating NOOB = new Rating(1, "U SO NOOB");
public static Rating EXPERT = new Rating(2, "U A PRO BRO");
private int rating;
private String message;
public Rating(int rating, String message) {
this.rating = rating;
this.message = message;
}
...
}