Part 17 - Macros
There are two ways to call the
- With only one argument
- With two or more arguments
In the second case, for every case except the last, it will write the string to the screen, write a space, then move on.
In the end, the two will have the same end result.
assert Macro makes sure that a condition is true, otherwise it raises an
assert can be called with one or two arguments.
The first argument must always be a boolean condition.
The optional second argument is a string that will be sent if the condition fails.
using Macro can take any number of arguments, it merely duplicates its behavior each time.
It creates a safety net for objects to be handled during a block, then disposed of as soon as that block is finished.
There are three types of arguments you can declare:
<object> = <expression>
In all three of these, it checks if the underlying
object is an
IDisposable, which it then disposes of afterward.
This will create the file, write to it, then close it as soon as the
using block is finished. Makes it very safe and convenient.
lock Macro makes sure that, in a multithreaded environment, that a specified object is not being used and prevents another object from using it at the same time.
lock must accept at least one argument, and it will put the
lock on all that are given.
debug Macro is the exact same as the
System.Diagnostics.Debug instead of
Go on to Part 18 - Duck Typing