バックスペース(\b)をコンソールに出力したら、バックスペースする

昨日のJGGUG 第4回「Groovyイン・アクション」読書会 IN 関西 開催 にて Groovyイン・アクション の P-244 Thread.sleep を使った例で提示されているコードを動かしてみて感動した!

Groovyイン・アクション P-244 コード抜粋

text = """
This text appears
slowly on the screen
as if someone would
tpye \b\b \b\b \b\b \bype it.
"""
for (c in text) {
  sleep 100
  print c
}

つい C# でも書いてみた。

using System;
using System.Threading;

class Program
{
  static void Main(string[] args)
  {
    var s = string.Format(@"
This text appears
slowly on the screen
as if someone would
tpye {0}{0} {0}{0} {0}{0} {0}ype it.
", "\b");
    foreach (var c in s)
    {
      Thread.Sleep(100);
      Console.Write(c);
    }
    Console.ReadKey();
  }
}

一晩経って考えたら、結構当たり前の事なんだよなと。改行(\n)入れたら改行されるのは普通だと思ってるのに、なんでバックスペース(\b)だと感動したんだろう?
表示されている文字が消える、実際にタイプしている様に見えた ってのが感動の要因だったのかなぁ〜?