On Tuesday, 12 July 2022 at 22:58:32 UTC, Steven Schveighoffer wrote:
```d
string a = "abcabc";
assert(a[0 .. 3] ==  a[3 .. $])
assert(a[0 .. 3] !is a[3 .. $])
```

The point is, `==` compares *value*, `is` always compares *identity*.

Consider null type array which is a related topic but it cannot get a null element! The first is ok, but the second is legal. So no effect, is it normal?

```d
auto p = [ null, null ];//*
  assert(
    is(typeof(null)[] :
       typeof(p)
    )
  ); /* and it has two(2) elements */

  p ~= null;             // okay
  assert(p.length == 3); // true

  p ~= [];               // legal (no error)
  assert(p.length != 4); // what! (no effect)

  assert(p[0] == []);    // true
  assert([] == null);    // right on

  import std.stdio;
  typeid(p).write(": ", p.length);
  writeln("->", []); // typeof(null)[]: 3->[]
```

SDB@79

Reply via email to