Reputation: 11
When we define an enum type, we may need some comments for each case.
I know we can have a comments syntax like this in Obj-C:
enum Example
{
Example1, ///< Comments for Example1.
Example2, ///< Comments for Example2.
Example3. ///< Comments for Example3.
}
My question is: How to do this in swift?
Upvotes: 1
Views: 324
Reputation: 5259
You can use double stars to show the comment at a summary:
enum Example {
/** Comments for Example1. (with stars) */
case example1
/// Comments for Example2. (with three slash)
case example2
/// Comments for Example3. (with three slash)
case example3
}
here is a reference
Upvotes: 1
Reputation: 1
Kind of unclear what your question is - adding "//" will make the rest of the code on that line a comment. So you should do:
enum Example
{
Example1, // Comments for Example1.
Example2, // Comments for Example2.
Example3. // Comments for Example3.
}
Or, you could just do it how you did with obj-c. Both should work fine.
Upvotes: 0