Example.create(
attribute1 = "asdf",
attribute2 = "asdf2",
attribute3 = "and 20 more attributes"
)
但是我如何方便地制作
variable2 = "qwer"
if random_thing == "zxcv"
,而不必在 if/else 中使用两个(几乎)相同的创建方法?
也许通过使用三元运算符:
Example.create(
attribute1 = "asdf",
attribute2 = random_thing == "zxcv" ? "qwer" : "asdf2",
attribute3 = "and 20 more attributes"
)