Multi-line struct assignment
rgreenjr opened this issue · comments
Ron Green commented
I'd appreciate verification on the preferred way to wrap multi-line struct assignments. The three possible scenarios are depicted below.
Thanks in advance!
- Left hand side fits, but right doesn't:
datetime =
%NaiveDateTime{calendar: Calendar.ISO, day: 1, month: 12, year: 2017}
- Right hand side fits, but left doesn't:
%NaiveDateTime{calendar: calendar, day: day, month: month, year: year} =
datetime_struct
- Neither right nor left hand side fits:
%NaiveDateTime{
calendar: calendar,
day: day,
hour: hour,
microsecond: microsecond,
minute: minute,
month: month,
second: second,
year: year} =
%NaiveDateTime{
calendar: Calendar.ISO,
day: 1,
hour: 23,
microsecond: {0, 0},
minute: 59,
month: 1,
second: 59,
year: 2017
}
Louis Pilfold commented
Any preference here? I'm thinking this:
Left hand side fits, but right doesn't:
datetime = %NaiveDateTime{
calendar: Calendar.ISO,
day: 1,
month: 12,
year: 2017,
}
Right hand side fits, but left doesn't:
%NaiveDateTime{calendar: calendar, day: day, month: month, year: year} =
datetime_struct
Neither right nor left hand side fits:
%NaiveDateTime{
calendar: calendar,
day: day,
hour: hour,
microsecond: microsecond,
minute: minute,
month: month,
second: second,
year: year,
} = %NaiveDateTime{
calendar: Calendar.ISO,
day: 1,
hour: 23,
microsecond: {0, 0},
minute: 59,
month: 1,
second: 59,
year: 2017,
}
Ron Green commented
Closing now that the code formatter has been released in Elixir v1.6.