Comment

Comment by zackmorris

Cool stuff, but I miss the "it" variable from HyperTalk (the language used by HyperCard) which contained the result of prompts to the user. Just search for "The it variable":

http://www.jaedworks.com/hypercard/HT-Masters/scripting.html

  ask "How many minutes do you want to play?"
  put it * 60 into timeToPlay  -- convert it into seconds
Today we could have a reserved keyword that holds the result of the last statement executed. A practical example adapted from the article using "it" might look like:

  Object.keys(envars)
  it.map(envar => `${envar}=${envars[envar]}`)
  it.join(' ')
  `$ ${it}`
  chalk.dim(it, 'node', args.join(' '))
  console.log(it);
A better name for "it" today might be "_", "result" or perhaps '$' in a shell-inspired language like php. Most shells support "$?" so that could work too:

  # prints 0
  true ; echo $?
  
  # prints 1
  false ; echo $?
parent zackmorris 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton