首页 \ 问答 \ 逗号有时不是多余的吗?(Isn't comma sometimes redundant? [closed])

逗号有时不是多余的吗?(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
更新时间:2023-07-31 18:07

最满意答案

这不是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.

相关问答

更多
  • 这不是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() ,但你没有向我们展示那样做的代码。 ...
  • 这是卷曲的工作原理: 首先,它连接到您提供的URL。 然后,它通过CURLOPT_TIMEOUT选项执行您指定的秒数的整体卷曲操作。 因此,如果将CURLOPT_TIMEOUT为-2,则在连接到主机后将永远不会执行。 要验证这一点,请通过启用CURLOPT_VERBOSE选项来运行脚本。 而且你总能获得以下信息。 * Operation timed out after -2000 milliseconds with 0 bytes received This is how curl works: Firs ...
  • 我相信你可能会在默认情况下是60秒的php.ini中触发default_socket_timeout。 尝试改变,看看它是否工作。 如果没有,请尝试此操作。 $xml = file_get_contents($url); 这样做会使用你可以在这里阅读的包装器: http : //php.net/manual/en/wrappers.php 你还需要确保在php.ini中启用了file_get_contents使用的必需包装器(通常启用,因此你应该可以,但只需检查确认)。 使用它可以绕过超时时间,如果超时被 ...
  • 在搜索互联网寻求解决方案之后,我们决定坚持使用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.

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)