Fix 'Line is too long error' in a ruby file

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

fix ‘Line is too long error’ in a ruby file
<Below this line, add a link to the EXACT exercise that you are stuck at.>
how to fix Line is too long error in a ruby file without ignoring it and not introducing new errors.

<In what way does your code behave incorrectly? Include ALL error messages.>
I have tried giving the extra character in the next line using IDE. It is introducing new errors like ‘Ternary operators must not be nested. Prefer if or else constructs instead.’

```

Replace this line with your code.
creation_time: instance.respond_to?(:creation_time) ? (instance.creation_time.respond_to?(:to_hash) ? instance.creation_time.to_hash : instance.creation_time) : nil,

<do not remove the three backticks above>

These are warnings, not the errors, right?

If you want to fix both of them you can simply use if else constructions.


You usually want to avoid long lines because they are simply harder to read.

And nested ternary operators decrease readability of your code.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.