You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
Rubyには、文字列とシンボルという似て非なるものがある。 それぞれの使いドコロだったり、内部での扱われ方だったりはなんとなく分かってるつもりだったけど、いざ違いを説明しろと言われたら言葉に詰まるなーと思って整理してみる。 困ったときはリファレンスだ!ということで、Ruby2.3.0のシンボルのページを見てみたところ、ちょうどいい解説があったのでそれを参考に文字列との違いを見ていく。 http://docs.ruby-lang.org/ja/2.3.0/class/Symbol.html シンボルとは何なのか? 文字列はまぁ文字列だけど、シンボルってどんなものだろう? リファレンスによると、 Rubyの内部実装では、メソッド名や変数名、定数名、クラス名など の`名前'を整数で管理しています。これは名前を直接文字列として処理するよりも 速度面で有利だからです。そしてその整数をRubyのコード
Activerecord-Import is a library for bulk inserting data using ActiveRecord. One of its major features is following activerecord associations and generating the minimal number of SQL insert statements required, avoiding the N+1 insert problem. An example probably explains it best. Say you had a schema like this: Publishers have Books Books have Reviews and you wanted to bulk insert 100 new publish
まえがき yield ってなにがどうなっているのか (yeildが使われているコードの説明で) 自分で書くとこの設計できないのよね こんな感想をいただきました yield の理解を深めてもらうために、こんな使い方をしているよというコードベースでご紹介していきます 対象読者 yield がよくわからない人 yield がわかっているけど、自分の書くコードで使ったことがない人 yield ユースケース パフォーマンス監視 処理時間を記録して報告するような機能 module XXXReportable def with_reporting(name: ) started = Time.zone.now yield ended = Time.zone.now report(name: name, started: started, ended: ended) end private def rep
先日福岡で開催された RubyKaigi 2019 に参加してきました。下記の辻本さんのセッションの中で Ruby 2.7 で導入される予定のパターンマッチングについての紹介があったので、セッションの資料に沿って触ってみました。 Pattern matching - New feature in Ruby 2.7 - RubyKaigi 2019 セッションの資料は SpeakerDeck にアップロードされているのでそちらを参照させていただきました。 speakerdeck.com 今回使用しているサンプルコードは基本的には上記の資料内のサンプルをそのまま実行しているか、若干変更したものを使用しています。 パターンマッチングとは パターンマッチングについてのRubyist向けの説明としては、 case/when + multiple assignment という感じになり、正規表現とかで
RubyKaigi2019で聞いたRuby2.7から入るPattern Matchの機能に感動したのですが、セッション中は理解しきれない部分があったので、スライドを読み、コードを動かしてみました。 そしたら改めて感動した、という記事です! speakerdeck.com スライドのはじめに、下記の記載があります。 PatternMatchingは2.7.0からの新機能ですが、trunkにはもうcommit済 仕様はまだ策定中 試してフィードバックくださいね! なお、githubにサンプルコードを置いています。 1. 準備 Ruby2.7.0(dev)はビルドしなきゃかな…と思ってたらrbenvがもう対応してました。 はやい!うれしい! $ brew upgrade rbenv ruby-build これで無事2.7.0-devがリストに出てくるようになります。 $ rbenv instal
2018年12月14日、品川シーズンテラスカンファレンスにてRubyアソシエーションが主催するイベント「Ruby Business Users Conference 2018 Winter」が開催されました。すでにRubyを活用しているユーザーや、これからRubyをビジネスに活用しようと考えている人が集い、情報交換を行いました。基調講演「スタートアップの銀行口座残高と技術選定」に登壇したのは、株式会社SmartHR副社長兼最高開発責任者の内藤研介氏。創業から今日に至るまでの軌跡と、開発言語としてRubyを選択した理由を語ります。 スタートアップの銀行口座残高と技術選定 内藤研介氏:お疲れ様です。素晴らしいプレゼンばかりでしたね。もう、まつもと(ゆきひろ)さんの話も聞いたし目当てのプレゼンも聞いたし、花金だし。「そろそろ帰りたいな」なんて方もいらっしゃるかもしれないですが(笑)、もう少しだけ
Help us understand the problem. What is going on with this article? 2018/07/05 追記 JavaScript と漸進的型付について詳しい mizchi さんが記事を書いたので、併せて読むと良さそうです。 漸進的型付け言語の時代に必要なもの 前置き RubyKaigi2018 の発表で型の導入の検討についての話がいくつかあったものの、 Matz 自身は型アノテーションに否定的であるという発言をしているとのことを受けて、自分の意見の表明として書いている。 筆者は Ruby に育てられて Ruby は好きであるが、業務経験は主に JavaScript(TypeScript) や Python(Type Hinting) が多く、漸進的型付けによるコードの健全化を経験した上で、型付きの方が好きであるという立場である。 なお
概要 原著者の許諾を得て翻訳・公開いたします。 英語記事: Enumerable avoids using temporary variables when looping - Andy Croll 原文公開日: 2018/02/05 著者: Andy Croll Rubyで私の大好きな機能のいくつかはEnumerableモジュールにあります。このモジュールについて詳しくはRubyのドキュメントをどうぞ。 ArrayやSetやHashなどのような「コレクション」を表現するクラスでは、Enumerableのメソッドや機能が使えます。これらのメソッドを用いることで、そのグループをループで回して、コレクションの個別のメンバーを入力とする操作を行えます。 次のようには書かないこと C言語のように一時変数を用いてループする。多くの言語ではこれでよしとされている。 total = 0 [1, 3, 5
What goes in to a request and response in a Rails application? Where does the application get its data, and how does that data get to the client when you are done? In this talk we'll look at the request and response lifecycle in Rails. We'll start with how a request and response are serviced today, then move on to more exciting topics like adding HTTP2 support and what that means for developing Ra
Find actively maintained & popular open source software libraries for the Ruby programming languageThe Ruby Toolbox is a catalog of all Rubygems that keeps track of popularity and health metrics to help you choose a reliable library CategoriesTo give you an overview of what open source libraries are available for a given task we group projects for common problems into categories. The catalog itsel
CompanyEngineeringProductSunsetting AtomWe are archiving Atom and all projects under the Atom organization for an official sunset on December 15, 2022. January 30, 2023 Update: Update to the previous version of Atom before February 2 On December 7, 2022, GitHub detected unauthorized access to a set of repositories used in the planning and development of Atom. After a thorough investigation, we hav
be_a_rails_contributer.md これはなに Railsにプルリクストを送るときに知っておくと便利なお作法集 Railsにプルリクエストを送りたいけど何から始めたらいいのかわからない人向けの指針 お作法についてはRuby on Rails に貢献する方法 | Rails ガイドを参考にしています。 前提知識 Railsのコードを読むには、最低限次の二つの知識があったほうがよいです メタプログラミングRubyを読了した程度のRubyの知識 読もうとしている機能に関する知識をRuby on Rails ガイドなどで得ておく テスト環境 rails 自体のテストは rails-dev-box にある vagrant 環境越しにやります 基本的に各ライブラリ(例: activerecord)のディレクトリで rake test して実行します。全体は時間かかりすぎる>< rail
Highlights in Rails 5.0: Action Cable Rails API Active Record Attributes API Test Runner Exclusive use of rails CLI over Rake Sprockets 3 Turbolinks 5 Ruby 2.2.2+ required These release notes cover only the major changes. To learn about various bug fixes and changes, please refer to the changelogs or check out the list of commits in the main Rails repository on GitHub. 1 Upgrading to Rails 5.0If y
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く