A flag default value is the value of the flag that is created when defining flags in the code. Default values are mandatory and flags cannot be created without them. A default value is served when there is no configuration available, or no other value overrides it.
A boolean flag is false by default. To override the value, pass the desired value to the flag.
A string flag has an explicit configuration for its default value. In most languages, the first value is the default value, followed by an array of potential values.
With SDK version 5.0 or later
With SDK version 5.0 or later, use Rox.RoxString for String feature flags. |
The example code below, for SDK version 5.0 or later, creates a string flag for title color. The title can be White, Blue, Green, or Yellow. By default, it is White.
const flags = { titleColors: new Rox.RoxString('White', ['White', 'Blue', 'Green', 'Yellow']), };
const flags = { titleColors: new Rox.RoxString('White', ['White', 'Blue', 'Green', 'Yellow']), };
const flags = { titleColors: new Rox.RoxString('White', ['White', 'Blue', 'Green', 'Yellow']), };
import {RoxString} from 'rox-ssr'; const flags = { titleColors: new RoxString('White', ['White', 'Blue', 'Green', 'Yellow']), };
public class Flags implements RoxContainer { public final RoxFlag videoChat = new RoxFlag(true); public final RoxString titleColors = new RoxString("White", new String[] { "White", "Blue", "Green", "Yellow" }); public final RoxInt intFlag = new RoxInt(2, new int[] { 1, 2, 3 }); public final RoxDouble doubleFlag = new RoxDouble(2.2, new double[] { 1.1, 2.2, 3.3 }); }
using Io.Rollout.Rox.Server.Flags; public class Container : IRoxContainer { public RoxString TitleColorsVariant = new RoxString("White", new String[] {"White", "Blue", "Green", "Yellow"}); }
import "github.com/rollout/rox-go/v5/server" type Flags struct { TitleColors server.RoxString } var flags = & Flags { TitleColors: server.NewRoxString("White", [] string {"White", "Blue", "Green", "Yellow"}), }
from rox.core.entities.rox_string import RoxString class MyContainer: def __init__(self): self.title_colors = RoxString('White', ['White', 'Blue', 'Green'])
#import <rox/server.h> RoxStringBase *titleColor = rox_add_string("titleColors", "White", ROX_LIST_COPY_STR("White", "Blue", "Green", "Yellow"));
#import <rox/client.h> RoxStringBase *titleColor = rox_add_string_with_freeze_and_options("titleColors", "White", ROX_LIST_COPY_STR("White", "Blue", "Green", "Yellow"), RoxFreezeUntilLaunch);
#import <roxx/server.h> using namespace Rox; auto titleColor = String::Create("titleColors", "White", {"White", "Blue", "Green", "Yellow"});
#import <roxx/client.h> using namespace Rox::Client; auto titleColor = String::Create("titleColors", "White", {"White", "Blue", "Green", "Yellow"}, RoxFreezeUntilLaunch);
require 'rox/server/flags/rox_flag' require 'rox/server/flags/rox_string' require 'rox/server/flags/rox_int' require 'rox/server/flags/rox_double' class Container attr_accessor :video_chat attr_accessor :title_colors attr_accessor :title_size attr_accessor :special_number def initialize @video_chat = Rox::Server::RoxFlag.new(true) @title_colors = Rox::Server::RoxString.new('Blue', ['White', 'Blue', 'Green', 'Yellow']) @title_size = Rox::Server::RoxInt.new(8, [5, 13]) @special_number = Rox::Server::RoxDouble.new(2.71, [3.14, 0.577]) end end
#import "Flags.h" @implementation Flags - (instancetype)init { self = [super init]; if (self) { self.videoChat = [[ROXFlag alloc] initWithDefault:YES]; self.titleColors = [[ROXString alloc] initWithDefault:@"White" options:@[@"Blue", @"Green", @"Yellow"]]; self.intFlag = [[ROXInt alloc] initWithDefault:2 variations:@[@1, @2, @3]]; self.doubleFlag = [[ROXDouble alloc] initWithDefault:2.2 variations:@[@1.1, @2.2, @3.3]]; } return self; } @end
import Foundation import ROX public class Flags : RoxContainer { public let videoChat = RoxFlag(withDefault: true) public let titleColors = RoxString(withDefault: "White", variations: ["White", "Blue", "Green", "Yellow"]) public let intFlag = RoxInt(withDefault: 2, variations: [1, 2, 3]) public let doubleFlag = RoxDouble(withDefault: 2.2, variations: [1.1, 2.2, 3.3]) }
use Rox\Server\Flags\RoxDouble; use Rox\Server\Flags\RoxFlag; use Rox\Server\Flags\RoxInt; use Rox\Server\Flags\RoxString; class Container { public $videoChat; public $titleColor; public $titleSize; public $specialNumber; public function __construct() { $this->videoChat = new RoxFlag(false); $this->titleSize = new RoxInt(12, [14, 18]); $this->titleColor = new RoxString("White", ["Blue", "Green", "Yellow"]); $this->specialNumber = new RoxDouble(3.14, [2.71, 0.577]); } }
With SDK version 4.x
With SDK version 4.x, follow the below examples. |
The example code below, for SDK version 4.x, creates a string flag for title color. The title can be White, Blue, Green, or Yellow. By default, it is White.
const flags = { videoChat: new Rox.Flag(true), titleColors: new Rox.Variant('White', ['White', 'Blue', 'Green', 'Yellow']), };
const flags = { videoChat: new Rox.Flag(true), titleColors: new Rox.Variant('White', ['White', 'Blue', 'Green', 'Yellow']), };
const flags = { videoChat: new Rox.Flag(true), titleColors: new Rox.Variant('White', ['White', 'Blue', 'Green', 'Yellow']), };
import {Rox} from 'rox-ssr'; const flags = { videoChat: new Flag(true), titleColors: new Rox.Variant('White', ['White', 'Blue', 'Green', 'Yellow']), };
public class Flags implements RoxContainer{ public RoxFlag videoChat = new RoxFlag(true); public RoxVariant titleColors = new RoxVariant("White", new String[] {"White", "Blue", "Green", "Yellow"}); }
public class Flags : IRoxContainer { public RoxFlag videoChat = new RoxFlag(true); String[] TitleColorsOptions = new String[] {"White", "Blue", "Green", "Yellow"}; RoxVariant TitleColorsVariant = new RoxVariant("White", TitleColorsOptions); }
import ( "github.com/rollout/rox-go/v5/server" ) type Container struct { VideoChat server.RoxFlag titleColors server.RoxVariant } var container = &Container { VideoChat: server.NewRoxFlag(true), titleColors: server.NewRoxVariant("White", []string{"White", "Blue", "Green", "Yellow"})} }
from rox.server.flags.rox_flag import RoxFlag class MyContainer: def __init__(self): self.video_chat = RoxFlag(True) self.title_colors = RoxVariant('White', ['White', 'Blue', 'Green', 'Yellow'])
RoxVariant *videoChat = rox_add_flag("demo.video_chat", true); RoxVariant *titleColor = rox_add_variant("titleColors", "White", ROX_LIST_COPY_STR("White", "Blue", "Green", "Yellow"));
Rox::Flag *videoChat = Rox::Flag::Create("demo.video_chat", true); Rox::Variant *titleColor = Rox::Variant::Create("titleColors", "White", std::vector<std::string>{"White", "Blue", "Green", "Yellow"});
require 'rox/server/flags/rox_flag' class Container attr_accessor :video_chat attr_accessor :title_colors def initialize @video_chat = Rox::Server::RoxFlag.new(true) @title_colors = Rox::Server::RoxVariant.new('White', ['White', 'Blue', 'Green', 'Yellow']) end end
#import "Flags.h" @implementation Flags - (instancetype)init { self = [super init]; if (self) { self.videoChat = [[ROXFlag alloc] initWithDefaultValue:YES]; self.titleColors = [[ROXVariant alloc] initWithDefault:"White" options:@[@"Blue", @"Green", @"Yellow"]]; } return self; } @end
import Foundation import ROX public class Flags: RoxContainer{ public let videoChat = RoxFlag(withDefault: true); public let titleColors = ROXVariant(withDefault: "White", options: ["White", "Blue", "Green", "Yellow"]); }
use Rox\Server\Flags\RoxFlag; use Rox\Server\Flags\RoxVariant; class Container { public $videoChat; public $titleColors; public function __construct() { $this->videoChat = new RoxFlag(true); $this->titleColors = new RoxVariant("White", ["Blue", "Green", "Yellow"]); } }