relative static method

List<String> relative(
  1. RbxPath from,
  2. RbxPath to
)

Implementation

static List<String> relative(RbxPath from, RbxPath to) {
  int diffIndex = from.length > to.length ? from.length : to.length;
  final minLen = from.length < to.length ? from.length : to.length;
  for (int i = 0; i < minLen; i++) {
    if (from[i] != to[i]) {
      diffIndex = i;
      break;
    }
    if (i == minLen - 1) diffIndex = minLen;
  }
  return [
    for (int i = 0; i < from.length - diffIndex; i++) 'Parent',
    for (int i = diffIndex; i < to.length; i++) to[i],
  ];
}