<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Ruby on 世界杯买球网中文站-2026FIFA赛事动态速览</title><link>https://zh-space-fifa2026.com/tags/ruby/</link><description>Recent content in Ruby on 世界杯买球网中文站-2026FIFA赛事动态速览</description><generator>Hugo -- gohugo.io</generator><language>zh-cn</language><copyright>You</copyright><lastBuildDate>Mon, 18 May 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://zh-space-fifa2026.com/tags/ruby/index.xml" rel="self" type="application/rss+xml"/><item><title>Ruby 语言学习笔记：从入门到进阶</title><link>https://zh-space-fifa2026.com/posts/ruby-yu-yan-xue-xi-bi-ji-cong-ru-men-dao-jin-jie/</link><pubDate>Mon, 18 May 2026 00:00:00 +0000</pubDate><guid>https://zh-space-fifa2026.com/posts/ruby-yu-yan-xue-xi-bi-ji-cong-ru-men-dao-jin-jie/</guid><description>Ruby，这门由松本行弘（Matz）创造的语言，以其优雅的语法、纯粹的面向对象设计以及强大的元编程能力，吸引了无数开发者。它的核心理念是“开发者愉悦”，力求让编程过程变得更加自然和高效。本文将记录我在学习Ruby过程中的一些笔记，从基础语法到进阶概念，希望能为其他Ruby初学者提供参考。
一、 Ruby 的基本语法与特性
语法简洁优雅： Ruby的代码可读性极强，许多地方省略了括号、分号等，使得代码看起来像伪代码。
1def greet(name) 2 puts &amp;#34;Hello, #{name}!&amp;#34; # 字符串插值 3end 4 5greet(&amp;#34;World&amp;#34;) 一切皆对象： Ruby中，数字、字符串、类甚至nil都是对象。这意味着你可以调用方法在任何对象上。
15.times do 2 puts &amp;#34;This is an object.&amp;#34; 3end 4 5&amp;#34;hello&amp;#34;.upcase # =&amp;gt; &amp;#34;HELLO&amp;#34; 动态类型： Ruby是动态类型语言，变量的类型在运行时确定，无需显式声明。
代码块（Blocks）、迭代器（Iterators）和Procs/Lambdas： 这是Ruby中最具特色的功能之一。代码块是传递给方法的匿名代码片段，常与迭代器（如each, map, select）结合使用，实现强大的集合处理能力。
1[1, 2, 3].each do |num| 2 puts num * 2 3end 4 5# Proc 6my_proc = Proc.new { puts &amp;#34;This is a Proc.&amp;#34; } 7my_proc.call 8 9# Lambda (更严格的Proc，对返回有不同处理) 10my_lambda = lambda { |x| return x * 2 } 11puts my_lambda.</description></item></channel></rss>