Skip to Content
Raku学习手册
book

Raku学习手册

by brian d foy
October 2020
Beginner to intermediate
499 pages
9h 13m
Chinese
China Electric Power Press Ltd.
Content preview from Raku学习手册
字符串
73
单引号,因为这种方式键入更容易。不论你使用什么引号方法,都会得到相同类型
的对象。
4.2.2
字符串操作符和方法
可以使用连接(
concatenation
)操作符
~
合并
Str
。有些人把这称为“字符串相加”。
输出显示两
Str
成为一个
Str
,两个
Str
紧挨着,之间没有任何其他字符:
my $name = 'Hamadryas'
~
'perlicus';
put $name; # Hamadryasperlicus
你可以自己增加空格,即在某个
Str
中加一个空格,也可以一次连接多个
Str
put 'Hamadryas '
~
'perlicus';
put 'Hamadryas'
~
' '
~
'perlicus';
join
例程可以用你提供的第一个
Str
把后面的
Str
黏合在一起:
my $butterfly-name = join ' ', 'Hamadryas', 'perlicus'
可以通过重复一个
Str
来建立更大的
Str
x
Str
复制
操作符。它会把
Str
重复你
指定的次数。这对于为输出建立一个基于文本的分隔线或标尺会很方便:
put '-' x 70;
put '.123456789' x 7;
.chars
方法会告诉你
Str
中有多少个字符:
put 'Hamadryas'.chars; # 9
至少有一个字符的
Str
转换为布尔值都是
True
,这包括只有单个字
0
Str
put ?'Hamadryas'; # True
put ?'0'; # True ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

可编程网络自动化

可编程网络自动化

Jason Edelman, Scott S. Lowe, Matt Oswalt
程序员学数据结构

程序员学数据结构

Posts & Telecom Press, William Smith
R深度学习权威指南

R深度学习权威指南

Posts & Telecom Press, Joshua F. Wiley
AI工程

AI工程

Chip Huyen

Publisher Resources

ISBN: 9787519848002