Q:

How does Ruby parse: a.b = B.new a.b.c = C.new?

I'm assuming it treats it as
a.b = (B.new (a.b.c = C.new))

This is the line:
request.transactionRequest.payment = PaymentType.new request.transactionRequest.payment.creditCard = CreditCardType.new('4242424242424242','0220','123')

https://developer.authorize.net/hello_world/
I'm assuming it would treat it as

request.transactionRequest.payment = ( PaymentType.new ( request.transactionRequest.payment.creditCard = CreditCardType.new('4242424242424242','0220','123') ) )

How would payment.creditCard get assigned if payment is even set yet? Wouldn't that generate a nil pointer error? Even if it worked, why would you do that to overwrite payment when you just set payment.creditCard?

A:

It's missing a newline, that's all:
request.transactionRequest.payment = PaymentType.new
request.transactionRequest.payment.creditCard = CreditCardType.new('4242424242424242','0220','123')

Although the one-line version is valid Ruby syntax, it's also not something you'd do in production code without good cause.

