Setting the flag default values

This section describes flag default values and how to set them.

What are default values?

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. They will be served when there is no configuration available (for any reason) or no other value overrides it.

Setting flag default value

A boolean flag is false by default. To override the value, pass the desired value to the flag.

A string flag (multivariate) has an explicit configuration for its default value.  In most languages, the first value would be the default value followed by an array of potential values.

Swift Objective-C Android React Native JavaScript Node.js JavaScript SSR JVM .NET Python Go PHP Ruby C C++
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"]);
}
#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
public class Flags implements RoxContainer{
  public RoxFlag videoChat = new RoxFlag(true);
  public RoxVariant titleColors = new RoxVariant("White", new String[] {"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']),
};
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);
}
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'])
import (
        "github.com/rollout/rox-go/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"})}
}
class Container
{
    public $video_chat;
    public $titleColors;

    public function __construct()
    {
        $this->video_chat = new RoxFlag(true);
        $this->titleColors = new RoxVariant("White", ["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
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"});