"He rushed to the exit, leaped down the stairs, and ran for the train."
Better programming is to factor out the action:
[socket, window, file]*.close()
[socket, window, file].each{|item| item.close()}
It sort-of exists in Lisp-inspired languages (anything from Arc to Lua to Io) with appropriate boilerplate, for example:
function apply(tbl, func) for key, val in ipairs(tbl) do func(val) end end apply({socket, window, file}, function (item) item.close() end)
$_.close() for $socket, $window, $file;
[socket,window,file].forEach(function(o){o['close']();});
[socket, window, file].map(&:close)
class A{ def close(){println "closed"} } def a1= new A() def a2= new A() [a1, a2]*.close()
"He rushed to the exit, leaped down the stairs, and ran for the train."
Better programming is to factor out the action: