この記事は Speee Advent Calender の25日目の記事です。 開発部 R&D グループの村田です。所謂フルタイム CRuby コミッターの一人です。 今日は 12/25 です。数時間後には Ruby 2.5.0 がリリースされている予定です。 皆さんはもう RC1 を試しましたか?え?毎日 trunk をビルドして使っているって?とても素晴らしいですね。 しかし、そうじゃ無い人も大勢いると思います。ですから、ここでは Ruby 2.5.0 で何がどう変わったのか、インパクトが大きいものを選んで最終確認をしておきましょう。 まとめ方は以下のようにしました*1。 言語仕様の変更 組み込みクラスの変更 パフォーマンス改善 言語仕様の変更 トップレベルで定義された定数の検索 トップレベルで定義された定数はObjectクラスの下に定義されたことになります。 TWO = 2 Obje
ブログ記事 からの転載です。 Ruby 2.5 系で CSV.generate を使用しようとしたら意図しない動作をして、調べてみたらバグだったのでそのまとめ。 しかし、これ、結構クリティカルなバグだと思うんですけど、全然話題になってないのが不思議(当時は話題になっていたのかもしれないけど。 CSV.generate とは 以下のような感じで CSV 形式で文字列を構築する事が出来ます。 # Ruby 2.4 で実行 require "csv" require "pp" result = CSV.generate do |csv| csv << [1, 2, 3] csv << ["homu", "mami", "mado"] end pp result # => "1,2,3\n" + "homu,mami,mado\n" require "csv" require "pp" csv =
Ubiregi Advent Calendar 2018 の 5 日目です。 同僚が「Ruby 2.5 が SEGV するんだけど」というので調べて見たときの話です。結論から言うと Ruby 2.6 では直っています。 クラッシュログ 同僚の変更内容を手元の macOS で動かすと確かに SEGV して以下の様なクラッシュログが出力されていました。 Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_BAD_ACCESS (SIGABRT) Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY VM Regions Near 0: --> __TEXT 000
Before Ruby 2.5, if we want to log a caught exception, we would need to format it ourselves. 1class AverageService 2 attr_reader :numbers, :coerced_numbers 3 4 def initialize(numbers) 5 @numbers = numbers 6 @coerced_numbers = coerce_numbers 7 end 8 9 def average 10 sum / count 11 end 12 13 private 14 15 def coerce_numbers 16 numbers.map do |number| 17 begin 18 Float(number) 19 rescue Exception =>
技術部でフルタイム Ruby コミッタをしている笹田です。最近ひさびさに Ruby のライブラリに pull request をしました(show valid break point lines #393)。 12/25 のクリスマスに、Ruby 2.5 が無事にリリースされました(Ruby 2.5.0 リリース)。関係各位の努力に感謝します。いろいろなバグ修正、いろいろな新機能、いろいろな性能改善があります(詳細は、上記リリースノート、もしくは Ruby のソースコードにある NEWS ファイルをご参照ください)ので、試して頂けると良いと思います。そういえば、私がクックパッドに入社して初めての Ruby リリースでした。 前回の techlife ブログ( Ruby の NODE を GC から卒業させた )で遠藤さんが クックパッドからの主な貢献としては、「trace 命令の削除による
Ruby 2.5 は引数に &block を書いても速い!!! #megurorb Meguro.rb#10 で「引数に &block を書いても速い!!!」という素晴らしい改善について話してきた。 b.r-l.o の issue で言うとこちら。 Feature #14045: Lazy Proc allocation for block parameters 前提知識 block の呼び出し方 3 パターン block をメソッドで使う場合、大きく分けてこの 3 パターンがあると思う。 # block を引数で受け取って、call で呼ぶ def block_call_with_block_arg(&block) block.call end # block を引数で受け取らずに yield で呼ぶ def yield_without_block_arg yield end # 引数で
Back in November, I posted speed results for Ruby 2.5.0 preview 1. It was barely faster than Ruby 2.4, which was a bit of a disappointment. However, one very important performance patch landed before it finished, which made a big difference in the final speed. How big? Let's see, shall we? Quick GraphsYou just want to see the graphs, I'll bet. I'm the same way. Here's a great start: total-time run
…the name still sucks, tho As you probably have been told, Ruby 2.5 has introduced Kernel#yield_self method, now available in any object. On the first sight, it does nothing fancy: just, as the name suggests, yields object it is applied to and returns the result: # before url = construct_url response = Faraday.get(url) data = JSON.parse(response.body) id = data.dig('object', 'id') || '<undefined>'
In Ruby, structs can be created using positional arguments. 1Customer = Struct.new(:name, :email) 2Customer.new("John", "john@example.com")Copy This approach works when the arguments list is short. When arguments list increases then it gets harder to track which position maps to which value. Here if we pass keyword argument then we won't get any error. But the values are not what we wanted. 1Custo
Ruby’s performance is getting better and better with each release and the newly released 2.5.0 version is no different. Before the release of Ruby 2.4 last year I benchmarked Ruby 2.3.3p222 and 2.4.0preview3 and was pleasantly surprised. Since the release notes of Ruby 2.5 highlight some performance improvements I ran another benchmark. This time I benchmarked Ruby 2.3.6, 2.4.3 and 2.5.0 on all th
Ruby 2.5.0 was recently released. Ruby has sequence predicates such as all?, none?, one? and any? which take a block and evaluate that by passing every element of the sequence to it. 1if queries.any? { |sql| /LEFT OUTER JOIN/i =~ sql } 2logger.log "Left outer join detected" 3endCopy Ruby 2.5 allows using a shorthand for this by passing a pattern argument. Internally case equality operator(===) is
Ruby25 の参加申し込み用ページです。 Ruby25 はRuby25周年を記念したイベントです。 25年を振り返り、皆さまとお祝いし、Rubyの今、そして未来を展望するイベントにしたいと思っています。 詳細はイベントスケジュールをご参照ください。 チケットの種類は下記の通りです。 一般(2,000円) 学生(無料) Ruby 貢献者(無料) Ruby に貢献された方向けのチケットです。例えば、下記のような貢献を想定しています(これらに限りません)。とくに入力内容はチェックしません。 Ruby に関する OSS 貢献者 コミュニティ主催 Rubyに関する書籍執筆者 申込時に入力いただいたお名前と貢献内容を公開することがあります。 配偶者の方など、ご招待したい方がいらっしゃいましたら ruby25@ruby.or.jp までご一報ください。招待枠を用意します。 なお、プレスの方にはプレスチ
With the upcoming release of ruby v2.5 scheduled (as per tradition) for 25th December, it’s good to know what’s changed in the language - so you can take advantage any new (or refined) features. This popular blog post by Junichi Ito highlighted 10 new features; but since there are so many improvements to the language, let’s dive in and unravel 10 more handpicked highlights! 1. More public Module m
はじめに Rubyは毎年12月25日にアップデートされます。 今年はまだpreview版がリリースされていませんが(2017年10月10日時点)、今年もそろそろリリースの日が近づいてきました。 Ruby 2.5については2017年10月10日にpreview1がリリースされました。 Ruby 2.5.0-preview1 Released そこでこの記事ではこの2.5.0-preview1を参考にして、おそらくこんな感じでリリースされるであろうRuby 2.5の新機能や変更点をまとめてみました。 2017.12.25追記: Part 2もあります! この記事を公開したあとにも多数新機能が追加されました。この記事に追記すると長くなってしまうので、Part 2として公開しています。こちらもあわせてご覧ください。 サンプルコードでわかる!Ruby 2.5の主な新機能と変更点 Part 2 - Q
Ruby 2.5 added a new method named yield_self. It yields the receiver to the given block and returns output of the last statement in the block. 1irb> "Hello".yield_self { |str| str + " World" } 2 => "Hello World"Copy How is it different from try in Rails ? Without a method argument try behaves similar to yield_self. It would yield to the given block unless the receiver is nil and returns the output
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く