Comments
Introduction
Like most programming languages, MagiScript provides commenting capabilities that allow developers to annotate their code with useful information without affecting the code’s functionality.
Single-line Comments
Single-line comments in MagiScript are similar to those in JavaScript and are denoted by the two forward slashes (//
). Anything written after the //
on the same line will be considered a comment and will be ignored by the interpreter. Here is an example of a single-line comment:
// This is a single-line comment in MagiScript
let x = 10; // This will set x to 10.
Multi-line Comments
MagiScript also supports multi-line comments, which are useful when you want to add comments that span multiple lines. Multi-line comments start with /*
and end with */
. Here is an example of a multi-line comment:
/*
This is a multi-line comment in MagiScript
It can span multiple lines
*/
Tips for Writing Good Comments
Good comments can make your code more readable and easier to understand, especially for other developers who may be working with the same code. Here are some tips:
- Be concise and to the point. Comments should provide useful information without being too verbose.
- Use comments to explain the purpose of your code, not what it does. The code should be self-explanatory, and comments should focus on explaining why the code exists and what problem it solves.
- Use comments to clarify any complex or confusing code. If a particular line or section of code is difficult to understand, add a comment to explain it.
- Avoid commenting on obvious things. Comments that simply repeat what the code is doing are not useful and can be distracting.
- Make sure your comments are up to date. If you make changes to your code, update the comments to reflect those changes.
- Use meaningful variable and function names to explain what are they about, so you won’t need comments.
By following these tips, you can write comments that will make your code easier to read, understand, and maintain.
Conclusion
Comments are great to write notes about the code. You can use them to understand what the code does and help the reader. Don’t overuse them, comments those are not providing new information are not useful.
General
πΒ First Steps
MagiScript Editor
πΒ Basics
πΒ Running Your First Program
πΒ App Store
πΒ Atom Settings (Editor)
πΒ Debugging Techniques
Examples
πΒ Atom Time
ποΈ Time Practice
πΒ Atom Pi (Pi Revelations)
πΒ Atom Drum
ποΈ Atom Stack
πΒ Atom Square
πΒ Atom Level
πΒ Atom THMPR
πΒ Poker Hands
πΒ Keyboard Numeric
πΒ Keyboard NOKIA
πΒ Keyboard Cursor
πΒ Keyboard Media
πΒ Keyboard Custom
Input/Output
πΒ Buttons
πΒ Vibration Motor
πΒ RGB LED
πΒ Devices
πΒ PeekSmith
πΒ SB Watch
πΒ Bluetooth Keyboard
πΒ Bluetooth Mouse
πΒ Timers
πΒ Database
πΒ Events
πΒ System (exit, sleep, rand)
πΒ Objects (card, time)
Language
πΒ Summary
πΒ Comments
πΒ Variable Declarations
πΒ Operators
πΒ Control Flow
πΒ Functions
πΒ Numbers
πΒ Strings
πΒ Arrays
πΒ Objects
πΒ Uint8Array