我假设它将其视为
a.b = (B.new (a.b.c = C.new))
这是一行:
request.transactionRequest.payment = PaymentType.new request.transactionRequest.payment.creditCard = CreditCardType.new('4242424242424242','0220','123')
https://developer.authorize.net/hello_world/
我假设它会将其视为
request.transactionRequest.payment =(PaymentType.new(request.transactionRequest.payment.creditCard = CreditCardType.new(' 4242424242424242',' 0220',' 123&# 39;)))
如果payment.creditCard
已设置,如何分配payment
?不会产生零指针错误吗?即使它有效,为什么要在设置payment
时覆盖payment.creditCard
呢?
答案 0 :(得分:1)
缺少换行符,就是全部:
request.transactionRequest.payment = PaymentType.new
request.transactionRequest.payment.creditCard = CreditCardType.new('4242424242424242','0220','123')
虽然单行版本是有效的Ruby语法,但如果没有正当理由,它也不是你在生产代码中所做的事情。