+ 1
Needing of spaces and tabulatings
I've seen many codes that have spaces and tabs at the beginning of some lines. Is that obligatory or it's just used to keep an order/have a reference? I'm just a beginner. Sorry if my question is... dumb haha!
8 Answers
+ 17
@IvĂ n there are certain editors that add tabs automatically based on the language you are working with, i highly recommend you to check them out because a not-indented code is unprofessional and, most important, unreadable.
PS - The Sololearn editor adds automatically 4 spaces of indentation.
+ 4
@Maz: unfortunaly editors wanting to help users to indent are counterproductive in the hands of rookies: I suspect this automatic indent behaviour to be the reason of most of messy codes in playground (which often have randomly indentation: beginners don't know indentation -- except for Python or Ruby wich doesn't work without understading this concept -- and are too lazy to always delete the extra spaces automatically added without using them to do correct indentation of their code ;P)
+ 1
reference and order because if some line is tabulated usually it depends from less tabulated. For example code into a function or into a loop
+ 1
Thank you, Daniel! I will soon try and write a code but i sincerely forgot to space any line. It will work anyway then, thanks!
+ 1
if (a>5)
alert("Big");
the alert only run if condition is true.
In some languages indent not affect to code but in others like ruby yes, so is important you practice it for order your codes
+ 1
Got it. I will do so. Thanks again for your time!
+ 1
I'm starting now my code again since it was just a try. I thank you both, it's important to know that spme languages wouldn't work tithout this order, since I'll try and learn as much as i can/need to.
0
Ivan algunos lenguajes cuando estas dentro de funciĂłn por ejemplo, al pulsar intro te hacen la tabulaciĂłn en automĂĄtico. Puedes ver en los cursos aquĂ en SL como se usa siempre o casi siempre la tabulaciĂłn