TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Overriding the Backtick in Ruby

3 点作者 vijaydev超过 14 年前

2 条评论

draegtun超过 14 年前
This related <i>URLs in Ruby</i> HN post maybe of interest: <a href="http://news.ycombinator.com/item?id=994716" rel="nofollow">http://news.ycombinator.com/item?id=994716</a><p>This inspired me at the time to write PerlX::QuoteOperator (<a href="http://search.cpan.org/dist/PerlX-QuoteOperator/" rel="nofollow">http://search.cpan.org/dist/PerlX-QuoteOperator/</a>) which allows you to create new custom quote-like operators (<a href="http://perldoc.perl.org/perlop.html#Quote-Like-Operators" rel="nofollow">http://perldoc.perl.org/perlop.html#Quote-Like-Operators</a>).<p>So for example to create a URI quote-like operator called <i>u</i>:<p><pre><code> use PerlX::QuoteOperator u =&#62; { -emulate =&#62; 'q', -with =&#62; sub ($) { require URI; URI-&#62;new( $_[0] ); }, }; my $uri = u(http://google.com);</code></pre>
评论 #2025865 未加载
draegtun超过 14 年前
The <i>overriding unary operators</i> article referred to in post was discussed on HN. See <i>Charging Objects in Ruby</i> (<a href="http://news.ycombinator.com/item?id=2022107" rel="nofollow">http://news.ycombinator.com/item?id=2022107</a>)