I'm sure there is a more idiomatic ruby way to write the code below:
@var = obj['blah'] unless obj['blah'].nil?
I've got a whole load of these to do (see below), and there must be a nicer way!
@num_x = obj['num_x'] unless obj['num_x'].nil?
@num_y = obj['num_y'] unless obj['num_y'].nil?
@num_iterations = obj['num_iterations'] unless obj['num_iterations'].nil?
@pe = obj['pe'] unless obj['pe'].nil?
I have a feeling that the ||=
operator may be useful, but can't seem to quite work out how to use it.