Forum > Beginners
Nest assignment into if-statement
User137:
There was another option:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---if ex_func(ex_param, ex_var) = 0 thenbegin //whateverend;That just assumes ex_func() is made by you, and set the ex_var in it.
Edson:
Pascal syntax was made to be clear. Probably you will need more lines to implement, but it will be more readable. :)
wp:
--- Quote from: BrainChemistry on January 09, 2016, 10:53:06 am ---more lines of code, that is what I'd like to prevent :-).
--- End quote ---
I don't understand what's the problem of writing one more line of code. Cramping "everything" into a single line of code will cost you hours of debugging months later when you'll have forgotten all the details.
Leledumbo:
People come from C based languages tend to be lazier, because debugging is the last chapter they learn :D
BeniBela:
--- Quote from: wp on January 09, 2016, 06:31:24 pm ---
I don't understand what's the problem of writing one more line of code.
--- End quote ---
Every line of code is a liability.
The less code there is, the less time you will spend maintaining or debugging it in the long term.
You write one additional line here, and one there, and then they interact, and everything blows up
Navigation
[0] Message Index
[#] Next page
[*] Previous page