toExternal

Summary

Converts the Boolean value to its equivalent external value.

Usage

public override external toExternal()

Returns

The Boolean value held by the System.Boolean object.

Description

Converts the Boolean value to its equivalent external value.

Examples

Basic Usage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import System;
 
external mysql = { query: function(q, a) { Console.log(q, a); } };
 
// Constrain type arguments to only classes that can convert to 'external'
interface ICommand<T: IExportable>
{
    void execute(...T args);
}
 
class ToggleServer : ICommand<Boolean>
{
    final void execute(...Boolean args) {
        bool on = args[0] ?? false;
        mysql.query(
            """
            INSERT INTO `server`(`on`) VALUES(?)
            ON DUPLICATE KEY UPDATE `on` = ?;
            """,
            on.toExternal(),
            on.toExternal()
        );
    }
}
 
auto toggleServerCommand = new ToggleServer();
toggleServerCommand.execute(true);

Share

HTML | BBCode | Direct Link