root/examples/vmethods/bytes.pl

Revision 11293, 0.7 kB (checked in by Darren_Duncan, 3 years ago)

replaced all 'use v6;' lines with 'use v6-alpha;' in 330 files (examples/, ext/, t/, t_disabled/) ... more remain to do

  • Property svn:mime-type set to text/plain; charset=UTF-8
  • Property svn:eol-style set to native
Line 
1# Please remember to update examples/output/vmethods/bytes if you change this
2# file so its output will change.
3#
4# originally based on Ruby's ActiveSupport 1.0.4
5#
6
7use v6-alpha;
8
9multi sub bytes (Int $value:) {
10    $value;
11}
12
13our &byte:=&bytes;
14
15multi sub kilobytes (Int $value:) {
16    $value * 1024;
17}
18
19our &kilobyte:=&kilobytes;
20
21multi sub megabytes (Int $value:) {
22    $value * 1024.kilobytes;
23}
24
25our &megabyte:=&megabytes;
26
27multi sub gigabytes (Int $value:) {
28    $value * 1024.megabytes;
29}
30
31our &gigabyte:=&gigabytes;
32
33multi sub terabytes (Int $value:) {
34    $value * 1024.gigabytes;
35}
36
37our &terabyte:=&terabytes;
38
39say "5 bytes is " ~ 5.bytes ~ " bytes.";
40say "5 kilobytes is " ~ 5.kilobytes ~ " bytes.";
41say "1 megabyte is " ~ 1.megabyte ~ " bytes.";
Note: See TracBrowser for help on using the browser.