Jump to content

Documentation: Difference between revisions

Added Wren
No edit summary
(Added Wren)
Line 1,822:
 
{{omit from|M4}}
 
=={{header|Wren}}==
Wren source code has both single line (//) and block (/*..*/) comments. Block comments can also be nested.
 
However, there are currently no special tools for extracting documentation comments that I'm aware of.
<lang ecmascript>// The meaning of life!
var mol = 42
 
// A function to add two numbers
var add = Fn.new { |x, y| x + y }
 
/* A class with some string utilites */
class StrUtil {
// reverses an ASCII string
static reverse(s) { s[-1..0] }
 
// capitalizes the first letter of an ASCII string
static toTitle(s) {
var firstByte = s[0].bytes[0]
if (firstByte >= 97 && firstByte <= 122) {
firstByte = firstByte - 32
return String.fromByte(firstByte) + s[1..-1]
}
return s
}
}
 
// test code
var smol = "meaning of life"
System.print("'%(smol)' + 123 = %(add.call(mol, 123))")
System.print("'%(smol)' reversed = %(StrUtil.reverse(smol))")
System.print("'%(smol)' titled = %(StrUtil.toTitle(smol))")</lang>
 
{{out}}
<pre>
'meaning of life' + 123 = 165
'meaning of life' reversed = efil fo gninaem
'meaning of life' titled = Meaning of life
</pre>
 
 
=={{header|ZX Spectrum Basic}}==
9,490

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.