+ 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!

28th Oct 2017, 4:39 PM
Iván Domínguez
Iván Domínguez - avatar
8 odpowiedzi
+ 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.
28th Oct 2017, 4:49 PM
Maz
Maz - avatar
+ 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)
29th Oct 2017, 3:27 AM
visph
visph - avatar
+ 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
28th Oct 2017, 4:41 PM
Daniel
Daniel - avatar
+ 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!
28th Oct 2017, 4:43 PM
Iván Domínguez
Iván Domínguez - avatar
+ 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
28th Oct 2017, 4:44 PM
Daniel
Daniel - avatar
+ 1
Got it. I will do so. Thanks again for your time!
28th Oct 2017, 4:46 PM
Iván Domínguez
Iván Domínguez - avatar
+ 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.
28th Oct 2017, 4:57 PM
Iván Domínguez
Iván Domínguez - avatar
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
28th Oct 2017, 4:46 PM
Daniel
Daniel - avatar