openScope static method

  1. @experimental
Scope openScope({
  1. String scopeName = '',
  2. String separator = '.',
})

RU: Метод открывает дочерний Scope. ENG: The method open the child Scope.

Дочерний Scope открывается с scopeName Child Scope open with scopeName

Example:

final String scopeName = 'firstScope.secondScope';
final subScope = CherryPick.openScope(scopeName);

Implementation

@experimental
static Scope openScope({String scopeName = '', String separator = '.'}) {
  if (scopeName.isEmpty) {
    return openRootScope();
  }

  final nameParts = scopeName.split(separator);
  if (nameParts.isEmpty) {
    throw Exception('Can not open sub scope because scopeName can not split');
  }

  return nameParts.fold(
      openRootScope(),
      (Scope previousValue, String element) =>
          previousValue.openSubScope(element));
}