0

タスクは、curses lib を使用して、一定期間ユーザー入力なしで継続的に変化する情報を画面に出力することです。

次のコードはアイデアを示しています。

require 'curses'
include Curses

str = String.new

init_screen()
  5.times do |val|
  str << "This is the #{val} time we've done something.\n"
  addstr(str)
  getstr
  sleep 1
  clear
end

close_screen

Enter を 4 回押した後、出力は次のようになります。

This is the 0 time we've done something.
This is the 1 time we've done something.
This is the 2 time we've done something.
This is the 3 time we've done something.
This is the 4 time we've done something.

しかし、必要のない「getstr」を削除すると、何も出力されません。

そのような状況で呪いに対処する方法についてアドバイスや手がかりをいただければ幸いです. 前もって感謝します。

4

1 に答える 1