<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>编程 on 世界杯下注官方认证平台-世界杯下注官网-2026世界杯</title><link>https://zh-en-fifabets.com/tags/%E7%BC%96%E7%A8%8B/</link><description>Recent content in 编程 on 世界杯下注官方认证平台-世界杯下注官网-2026世界杯</description><generator>Hugo -- gohugo.io</generator><language>zh-cn</language><copyright>You</copyright><lastBuildDate>Fri, 15 May 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://zh-en-fifabets.com/tags/%E7%BC%96%E7%A8%8B/index.xml" rel="self" type="application/rss+xml"/><item><title>Ruby 语言学习笔记：核心概念与实践</title><link>https://zh-en-fifabets.com/posts/ruby-yu-yan-xue-xi-bi-ji-he-xin-gai-nian-yu-shi-jian/</link><pubDate>Fri, 15 May 2026 00:00:00 +0000</pubDate><guid>https://zh-en-fifabets.com/posts/ruby-yu-yan-xue-xi-bi-ji-he-xin-gai-nian-yu-shi-jian/</guid><description>Ruby 是一门优雅、动态、面向对象的脚本语言，以其简洁的语法和强大的元编程能力而闻名。它由日本程序员松本行弘（Yukihiro Matsumoto，昵称 Matz）开发，旨在提高程序员的生产力，让编程变得更愉快。本文将记录我在学习 Ruby 过程中的一些核心概念和实践心得。
Ruby 的哲学
Matz 曾说过：“Ruby 就像人类的自然语言一样，是一种富有表现力的语言。Ruby 旨在让编程变得更简单、更直观，让开发者能够专注于创造，而不是被复杂的语法和工具所困扰。” 这种哲学体现在 Ruby 的设计中，例如：
“最少惊奇原则” (Principle of Least Surprise): Ruby 的行为应该符合大多数程序员的直觉。 “程序员的友好” (Programmer&amp;rsquo;s Best Friend): Ruby 提供了许多便利的工具和语法糖，使得编写代码更加高效和愉悦。 一切皆对象
在 Ruby 中，万事万物都是对象，包括数字、字符串、甚至 nil。这意味着所有的数据类型都可以调用方法。
1# 数字是对象 2puts 5.class # =&amp;gt; Integer 3puts 5.to_s # =&amp;gt; &amp;#34;5&amp;#34; 4 5# 字符串是对象 6puts &amp;#34;Hello&amp;#34;.class # =&amp;gt; String 7puts &amp;#34;Hello&amp;#34;.length # =&amp;gt; 5 8 9# nil 也是对象 10puts nil.class # =&amp;gt; NilClass 11# puts nil.some_method # =&amp;gt; NoMethodError: undefined method `some_method&amp;#39; for nil:NilClass 面向对象编程</description></item></channel></rss>