Posts: 4,646
Threads: 1,493
Joined: Sep 2016
is there a preferred way of coding stuff like this (choose one line of these two):
working_column = self.columns[-1] if len(self.columns) > 0 else [0]
working_column = [0] if len(self.columns) < 1 else self.columns[-1]
or does it just not matter and is left to personal preference or arbitrary chance?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,646
Threads: 1,493
Joined: Sep 2016
(May-16-2017, 12:15 PM)metulburr Wrote: i personally avoid single line conditionals at all
do you have a reason for that which you believe others should consider?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,646
Threads: 1,493
Joined: Sep 2016
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,646
Threads: 1,493
Joined: Sep 2016
May-27-2017, 02:31 AM
(This post was last modified: May-27-2017, 02:31 AM by Skaperen.)
i like ternary operators when what i am having the code match ehat i am thinking. this would include a case where i am assigning a single target with a value or a different value or a case where an expression needs to vary based on a conditional. this is something i did even before i programmed in C. way back in my macro assembler days i wrote a set of macros to do structured programming. i included the capability to use a conditional to establish a value apart from the code that would store it, or use it in some way. i recognized that logic could have meanings like this and sought to make my code express the meaning as well as it could. so finding that C and Pike supported ?: and Python had a way (even if it was different) made me even happier with these languages.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.