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学习手册
练习答案
447
1
3
7
There are 5 arguments
1
3
7
6
5
There are 4 arguments
1
3
7
(6 5)
There are 3 arguments
1
3
(7 (6 5))
6.
你已经知道如何建立一个库导出子例程。对于这两个函数,你需要使用一个
slurpy
参数来扁平化参数。
head
返回第一个参数,
tail
返回其他参数。这两个
子例程的签名是一样的,而且两者都使用
is export trait
,会在加载这个库的作
用域中定义这两个子例程:
# HeadsTails.pm
sub head ( *@args ) is export { return @args[0] }
sub tail ( *@args ) is export { return @args[1..*-1] }
你可能发现其实你不需要做这个工作,因为已经有现成的
.head
.tail
方法。
12
章练习答案
1.
在使用类之前要先定义。大括号里不需要有任何代码。尽管看起来为空,但应该
也能从这些类创建对象:
class Butterfly {}
class Moth {}
class Lobster {}
my $number = Butterfly.new;
my $str = Moth.new;
my $set = Lobster.new;
2.
这个程序与前一个练习中的程序很类似。不过不是定义这些类,这里要用
use
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