逗号有时不是多余的吗?(Isn't comma sometimes redundant? [closed])
在Ruby中,从语言规范中删除了许多其他语言所需但被认为是多余的东西。 其中,一个重要的例子是分号。 除非您想连续输出语句,否则可以省略分号。
但是还有另一个角色,我通常觉得多余,而且在Ruby中仍然需要。 那是逗号。 在某些情况下,逗号不是冗余的,即,当方法参数或数组元素或哈希元素连续放在同一行上时,或者当它们被一对圆括号包围时,即使它们位于不同的行上? 为什么Ruby不能像shell脚本那样没有逗号,并且只能选择性地使用它们来指示方法参数/数组元素/哈希元素继续到下一行? 如果Matz继续选择分号,他为什么不用逗号来做?
我投票结束的这个问题让我想到了这个问题。
In Ruby, many things that were required in other languages but were felt redundant are removed from the language specification. Among them, one significant example is the semicolon. Unless you want to put statements consecutively, you can omit semicolons.
But there is another character that I usually feel redundant and is still required in Ruby. That is the comma. Isn't comma redundant in some cases, i.e., when method arguments or array elements or hash elements are put on the same line consecutively, or when they are surrounded by a pair of parentheses even when they are on different lines? Why cannot Ruby be without commas as with shell scripts, and use them only optionally to indicate that method arguments/array elements/hash elements continue onto the next line? If Matz went on and made semicolon optional, why didn't he do it for commas?
This question which I voted to close, made me think about this question.
原文:https://stackoverflow.com/questions/9659519
最满意答案
这不是cURL问题。
网站已启动 - 请求状态获取200(确定),脚本执行正常
但
当网站处于关闭状态时 - AJAX请求会一直发送/等待请求,直到获得200(OK)状态。
在这种情况下尝试避免使用AJAX并使用PHP发送cURL请求。
That's not the cURL problem.
While Website is UP - Request Status Gets 200(OK) and Script executes Fine
But
While Website is DOWN - The AJAX Request keeps sending/waiting for request until it gets 200(OK) Status.
Try Avoiding AJAX in this case and use PHP to send cURL Request.
相关问答
更多-
卷曲CURLOPT_TIMEOUT不起作用,脚本永远执行(curl CURLOPT_TIMEOUT doesnt works, script executes forever)[2022-03-06]
这不是cURL问题。 网站已启动 - 请求状态获取200(确定),脚本执行正常 但 当网站处于关闭状态时 - AJAX请求会一直发送/等待请求,直到获得200(OK)状态。 在这种情况下尝试避免使用AJAX并使用PHP发送cURL请求。 That's not the cURL problem. While Website is UP - Request Status Gets 200(OK) and Script executes Fine But While Website is DOWN - The A ... -
我通过使用shell_exec()来解决它。 echo shell_exec("curl https://feinternational.com/buy-a-website/9671-affiliate-e-commerce-survival-and-emergency-preparedness-34k-gross-mo"); 似乎有一个卷曲库与网站页面中的错误相结合的错误。 该错误并不一致。 有时命令行curl需要cookie,但大多数情况下不需要。 那么,我没有时间去调试curl,所以如果shell_ ...
-
要获取有关请求的信息,您可以查看curl_getinfo或curl_multi_info_read 并使用类似它的东西: curl_exec($ch); if(!curl_errno($ch)) { $info = curl_getinfo($ch); echo 'Took ' . $info['total_time'] . ' seconds to send a request to ' . $info['url']; } 在信息数组中,您可以接收以下数据: “URL” “内容类型” “HTTP_C ...
-
信不信由你... wait()和notify()工作得很好。 问题是您没有正确使用它们。 while(checkValues()==true){ System.out.println(name+" waiting"); wait(); } notify(); 这将等到其他一些线程通知this实例进行方法调用。 那不可能是notify(); 在循环之后打电话...'因为在你收到通知之前你无法到达那里。 现在有可能其他一些线程可以做那个notify() ,但你没有向我们展示那样做的代码。 ...
-
负卷曲超时(Negative curl timeout)[2023-02-19]
这是卷曲的工作原理: 首先,它连接到您提供的URL。 然后,它通过CURLOPT_TIMEOUT选项执行您指定的秒数的整体卷曲操作。 因此,如果将CURLOPT_TIMEOUT为-2,则在连接到主机后将永远不会执行。 要验证这一点,请通过启用CURLOPT_VERBOSE选项来运行脚本。 而且你总能获得以下信息。 * Operation timed out after -2000 milliseconds with 0 bytes received This is how curl works: Firs ... -
下载xml时卷曲超时(Curl timeout when downloading xml)[2023-08-14]
我相信你可能会在默认情况下是60秒的php.ini中触发default_socket_timeout。 尝试改变,看看它是否工作。 如果没有,请尝试此操作。 $xml = file_get_contents($url); 这样做会使用你可以在这里阅读的包装器: http : //php.net/manual/en/wrappers.php 你还需要确保在php.ini中启用了file_get_contents使用的必需包装器(通常启用,因此你应该可以,但只需检查确认)。 使用它可以绕过超时时间,如果超时被 ... -
永远运行Upstart(Run Upstart with Forever)[2022-02-23]
在搜索互联网寻求解决方案之后,我们决定坚持使用nodejs而不是永远用于此任务。 它更容易,并且通过重生它可以完成我们需要永远为我们做的一切。 start on runlevel [2345] stop on shutdown respawn script exec sudo nodejs /usr/lib/sites/path/Node/ourapp.js 2>&1 >> /var/log/ourapp.log end script After scouring the internet ... -
function get($url, $proxy){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_PROXY,$proxy); curl_setopt($ch, CURLOPT_TIMEOUT ,30); $response = curl_exec($ch); curl_close($ch); return $respons ...
-
您的libcurl版本可能存在错误。 也许您可以尝试升级到更新版本? 你可以在该系统上运行curl命令行工具(在特定的URL上)来调试会发生什么吗? 如果可以,使用-v或--trace-ascii选项应该很有价值,以准确显示curl的作用和不作用。 你的代码应该像写的一样工作。 There might be a bug in your version of libcurl. Perhaps you can try to upgrade to a more recent version? Can you ru ...
-
要关闭这个问题: 我正在使用的curl版本(7.15.5)不支持CURLOPT_TIMEOUT_MS。 据格雷格说,我需要至少7.16.2。 To close this question: The version of curl I am using (7.15.5) doesn't support CURLOPT_TIMEOUT_MS. According to Greg I need at least 7.16.2.