I was reading this thread https://stackoverflow.com/questions/268538/tab-versus-space-indentation-in-c-sharp reagrding Tab versus space indentation. The moral of the thread leads to “Tabs for indentation, spaces for alignment.” Can you explain me with some code example what does indentation means and what does spaces means wrt code? I am just confused with the two things in the context of code?
I was reading this thread https://stackoverflow.com/questions/268538/tab-versus-space-indentation-in-c-sharp reagrding Tab versus space indentation. The moral of
Share
Example from that thread:
here, keyword ‘case’ is indented. “bar:” and “foobar_2:” are aligned to the left.
You can imagine there is a box, where the same words can be either left- or right-aligned. Left:
Right:
as this kind of thing will become messed up if done with tabs due to different tab configuration, spaces are a must here. However, with different tab width configuration, indentation just becomes like this:
which is more a matter of preference as it does not mess up which line matches what.