Ideally, comments in your code are there to make it easier for other programmers to see what you've done or to explain actions that may be unclear. However, some people use the comment field for other purposes, not always easily deciphered. How do you use comments? Would other programmers be able to follow your logic?
Mostly just TODO
- Since Ruby is so expressive, and if you're doing things properly, code rarely needs explanation. I mostly use comments to leave TODO messages and such I can search for and fix later.
- —Guest HobbyCoder
Comment -- A way to remind
- Comment is best use for the enhancement in the code.. if we have two ways for doing the same way then we can comment any of them and use it in future as per requirement...
Also it can be used for the code readability plus maintainability..
- —Guest Minal Jain
Comments as Markers
- I often put a text marker into comments, so I can find my way back easily doing a "search in files."
- —Guest NohoDave
How I Use Comments in My Code
- How i can use comments in my ruby code and also send me various example how to create classes, moudles and functions
- —Guest prashant
For My Own Edification
- Typically I use comments in my code as a way to remind myself what I intended to happen or as a quick reminder as to what I need to add. I'm not sure other programmers would always understand my cryptic comments to myself, but it doesn't really matter that much to me.
- —Guest A Rubyist