Re:Httpx: A Ruby HTTP library
by pmontra on Wednesday October 30, 2019 @05:30AM
(#21395888)
Do you mean, that vs something like this?
My guess is that the focus of HTTPX being parallel requests, the author choose an API that explicitly groups them together. The documentation is pretty sparse, I wonder if we can pass an array of URLs to get().
[ Parent
| on HN ]
yes, ruby has a splat * operator that will basically expand an array into a set of arguments.
array = ["https://news.ycombinator.com/news", "https://news.ycombinator.com/news?p=2", "https://news.ycombinator.com/news?p=3"]
page1, page2, page3 = HTTPX.get(*array)Note you can also splat the return as well:
*pages = HTTPX.get(*urls)