News for hackers. Stuff that matters.
Re:Pipe Operator (|>) For JavaScript by zackmorris on Friday January 20, 2023 @11:59AM (#34456033)
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 $?
Re:Pipe Operator (|>) For JavaScript by jsnelgro on Friday January 20, 2023 @01:22PM (#34457354)
Kotlin uses "it" as the name of the implicit arg in lambdas. Makes things very readable imo:

``` listOf(1, 3, 5).map { it * 100 } ```

Re:Pipe Operator (|>) For JavaScript by ljharb on Monday January 30, 2023 @12:47AM (#34576223)
it, _, result, and $ are all valid identifiers already; the only choices would have to be syntax errors currently.