-
Notifications
You must be signed in to change notification settings - Fork 97
/
index.html
1429 lines (1123 loc) · 354 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="zh-cn"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>基本功能 · Julia中文文档</title><script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-28835595-9', 'auto');
ga('send', 'pageview', {'page': location.pathname + location.search + location.hash});
</script><link rel="canonical" href="https://juliacn.github.io/JuliaZH.jl/latest/base/base/"/><link href="https://fonts.googleapis.com/css?family=Lato|Roboto+Mono" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.0/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.0/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.0/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.11.1/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL="../.."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="../../assets/documenter.js"></script><script src="../../siteinfo.js"></script><script src="../../../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/documenter-dark.css" data-theme-name="documenter-dark"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="../../assets/themeswap.js"></script><link href="../../assets/julia-manual.css" rel="stylesheet" type="text/css"/></head><body><div id="documenter"><nav class="docs-sidebar"><a class="docs-logo" href="../../"><img src="../../assets/logo.png" alt="Julia中文文档 logo"/></a><div class="docs-package-name"><span class="docs-autofit">Julia中文文档</span></div><form class="docs-search" action="../../search/"><input class="docs-search-query" id="documenter-search-query" name="q" type="text" placeholder="Search docs"/></form><ul class="docs-menu"><li><a class="tocitem" href="../../">主页</a></li><li><span class="tocitem">手册</span><ul><li><a class="tocitem" href="../../manual/getting-started/">入门</a></li><li><a class="tocitem" href="../../manual/variables/">变量</a></li><li><a class="tocitem" href="../../manual/integers-and-floating-point-numbers/">整数和浮点数</a></li><li><a class="tocitem" href="../../manual/mathematical-operations/">数学运算和初等函数</a></li><li><a class="tocitem" href="../../manual/complex-and-rational-numbers/">复数和有理数</a></li><li><a class="tocitem" href="../../manual/strings/">字符串</a></li><li><a class="tocitem" href="../../manual/functions/">函数</a></li><li><a class="tocitem" href="../../manual/control-flow/">流程控制</a></li><li><a class="tocitem" href="../../manual/variables-and-scoping/">变量作用域</a></li><li><a class="tocitem" href="../../manual/types/">类型</a></li><li><a class="tocitem" href="../../manual/methods/">方法</a></li><li><a class="tocitem" href="../../manual/constructors/">构造函数</a></li><li><a class="tocitem" href="../../manual/conversion-and-promotion/">类型转换和类型提升</a></li><li><a class="tocitem" href="../../manual/interfaces/">接口</a></li><li><a class="tocitem" href="../../manual/modules/">模块</a></li><li><a class="tocitem" href="../../manual/documentation/">文档</a></li><li><a class="tocitem" href="../../manual/metaprogramming/">元编程</a></li><li><a class="tocitem" href="../../manual/arrays/">多维数组</a></li><li><a class="tocitem" href="../../manual/missing/">缺失值</a></li><li><a class="tocitem" href="../../manual/networking-and-streams/">网络和流</a></li><li><a class="tocitem" href="../../manual/parallel-computing/">并行计算</a></li><li><a class="tocitem" href="../../manual/asynchronous-programming/">异步编程</a></li><li><a class="tocitem" href="../../manual/multi-threading/">多线程</a></li><li><a class="tocitem" href="../../manual/distributed-computing/">多进程和分布式计算</a></li><li><a class="tocitem" href="../../manual/running-external-programs/">运行外部程序</a></li><li><a class="tocitem" href="../../manual/calling-c-and-fortran-code/">调用 C 和 Fortran 代码</a></li><li><a class="tocitem" href="../../manual/handling-operating-system-variation/">处理操作系统差异</a></li><li><a class="tocitem" href="../../manual/environment-variables/">环境变量</a></li><li><a class="tocitem" href="../../manual/embedding/">嵌入 Julia</a></li><li><a class="tocitem" href="../../manual/code-loading/">代码加载</a></li><li><a class="tocitem" href="../../manual/profile/">性能分析</a></li><li><a class="tocitem" href="../../manual/stacktraces/">栈跟踪</a></li><li><a class="tocitem" href="../../manual/performance-tips/">性能建议</a></li><li><a class="tocitem" href="../../manual/workflow-tips/">工作流程建议</a></li><li><a class="tocitem" href="../../manual/style-guide/">代码风格指南</a></li><li><a class="tocitem" href="../../manual/faq/">常见问题</a></li><li><a class="tocitem" href="../../manual/noteworthy-differences/">与其他语言的显著差异</a></li><li><a class="tocitem" href="../../manual/unicode-input/">Unicode 输入表</a></li><li><a class="tocitem" href="../../manual/command-line-options/">命令行选项</a></li></ul></li><li><span class="tocitem">Base</span><ul><li class="is-active"><a class="tocitem" href>基本功能</a><ul class="internal"><li><a class="tocitem" href="#介绍"><span>介绍</span></a></li><li><a class="tocitem" href="#Getting-Around"><span>Getting Around</span></a></li><li><a class="tocitem" href="#Keywords"><span>Keywords</span></a></li><li><a class="tocitem" href="#Standard-Modules"><span>Standard Modules</span></a></li><li><a class="tocitem" href="#Base-Submodules"><span>Base Submodules</span></a></li><li><a class="tocitem" href="#All-Objects"><span>All Objects</span></a></li><li><a class="tocitem" href="#Properties-of-Types"><span>Properties of Types</span></a></li><li><a class="tocitem" href="#Special-Types"><span>Special Types</span></a></li><li><a class="tocitem" href="#Generic-Functions"><span>Generic Functions</span></a></li><li><a class="tocitem" href="#Syntax"><span>Syntax</span></a></li><li><a class="tocitem" href="#Missing-Values"><span>Missing Values</span></a></li><li><a class="tocitem" href="#System"><span>System</span></a></li><li><a class="tocitem" href="#Versioning"><span>Versioning</span></a></li><li><a class="tocitem" href="#Errors"><span>Errors</span></a></li><li><a class="tocitem" href="#Events"><span>Events</span></a></li><li><a class="tocitem" href="#Reflection"><span>Reflection</span></a></li><li><a class="tocitem" href="#Internals"><span>Internals</span></a></li><li><a class="tocitem" href="#Meta"><span>Meta</span></a></li></ul></li><li><a class="tocitem" href="../collections/">集合和数据结构</a></li><li><a class="tocitem" href="../math/">数学相关</a></li><li><a class="tocitem" href="../numbers/">Numbers</a></li><li><a class="tocitem" href="../strings/">字符串</a></li><li><a class="tocitem" href="../arrays/">数组</a></li><li><a class="tocitem" href="../parallel/">Tasks</a></li><li><a class="tocitem" href="../multi-threading/">Multi-Threading</a></li><li><a class="tocitem" href="../constants/">常量</a></li><li><a class="tocitem" href="../file/">文件系统</a></li><li><a class="tocitem" href="../io-network/">I/O 与网络</a></li><li><a class="tocitem" href="../punctuation/">运算符与记号</a></li><li><a class="tocitem" href="../sort/">排序及相关函数</a></li><li><a class="tocitem" href="../iterators/">迭代相关</a></li><li><a class="tocitem" href="../c/">C 接口</a></li><li><a class="tocitem" href="../libc/">C 标准库</a></li><li><a class="tocitem" href="../stacktraces/">堆栈跟踪</a></li><li><a class="tocitem" href="../simd-types/">SIMD 支持</a></li></ul></li><li><span class="tocitem">Standard Library</span><ul><li><a class="tocitem" href="../../stdlib/Artifacts/">Artifacts</a></li><li><a class="tocitem" href="../../stdlib/Base64/">Base64</a></li><li><a class="tocitem" href="../../stdlib/CRC32c/">CRC32c</a></li><li><a class="tocitem" href="../../stdlib/Dates/">日期</a></li><li><a class="tocitem" href="../../stdlib/DelimitedFiles/">分隔符文件</a></li><li><a class="tocitem" href="../../stdlib/Distributed/">Distributed Computing</a></li><li><a class="tocitem" href="../../stdlib/FileWatching/">文件相关事件</a></li><li><a class="tocitem" href="../../stdlib/Future/">Future</a></li><li><a class="tocitem" href="../../stdlib/InteractiveUtils/">Interactive Utilities</a></li><li><a class="tocitem" href="../../stdlib/LazyArtifacts/">Lazy Artifacts</a></li><li><a class="tocitem" href="../../stdlib/LibGit2/">LibGit2</a></li><li><a class="tocitem" href="../../stdlib/Libdl/">动态链接器</a></li><li><a class="tocitem" href="../../stdlib/LinearAlgebra/">Linear Algebra</a></li><li><a class="tocitem" href="../../stdlib/Logging/">日志记录</a></li><li><a class="tocitem" href="../../stdlib/Markdown/">Markdown</a></li><li><a class="tocitem" href="../../stdlib/Mmap/">内存映射 I/O</a></li><li><a class="tocitem" href="../../stdlib/Printf/">Printf</a></li><li><a class="tocitem" href="../../stdlib/Profile/">性能分析</a></li><li><a class="tocitem" href="../../stdlib/REPL/">Julia REPL</a></li><li><a class="tocitem" href="../../stdlib/Random/">随机数</a></li><li><a class="tocitem" href="../../stdlib/SHA/">SHA</a></li><li><a class="tocitem" href="../../stdlib/Serialization/">序列化</a></li><li><a class="tocitem" href="../../stdlib/SharedArrays/">共享数组</a></li><li><a class="tocitem" href="../../stdlib/Sockets/">套接字</a></li><li><a class="tocitem" href="../../stdlib/SparseArrays/">稀疏数组</a></li><li><a class="tocitem" href="../../stdlib/Statistics/">统计</a></li><li><a class="tocitem" href="../../stdlib/TOML/">TOML</a></li><li><a class="tocitem" href="../../stdlib/Test/">单元测试</a></li><li><a class="tocitem" href="../../stdlib/UUIDs/">UUIDs</a></li><li><a class="tocitem" href="../../stdlib/Unicode/">Unicode</a></li></ul></li><li><span class="tocitem">Developer Documentation</span><ul><li><a class="tocitem" href="../../devdocs/reflection/">反射 与 自我检查</a></li><li><input class="collapse-toggle" id="menuitem-5-2" type="checkbox"/><label class="tocitem" for="menuitem-5-2"><span class="docs-label">Documentation of Julia's Internals</span><i class="docs-chevron"></i></label><ul class="collapsed"><li><a class="tocitem" href="../../devdocs/init/">Julia 运行时的初始化</a></li><li><a class="tocitem" href="../../devdocs/ast/">Julia 的 AST</a></li><li><a class="tocitem" href="../../devdocs/types/">More about types</a></li><li><a class="tocitem" href="../../devdocs/object/">Memory layout of Julia Objects</a></li><li><a class="tocitem" href="../../devdocs/eval/">Julia 代码的 eval</a></li><li><a class="tocitem" href="../../devdocs/callconv/">Calling Conventions</a></li><li><a class="tocitem" href="../../devdocs/compiler/">本机代码生成过程的高级概述</a></li><li><a class="tocitem" href="../../devdocs/functions/">Julia 函数</a></li><li><a class="tocitem" href="../../devdocs/cartesian/">笛卡尔</a></li><li><a class="tocitem" href="../../devdocs/meta/">Talking to the compiler (the <code>:meta</code> mechanism)</a></li><li><a class="tocitem" href="../../devdocs/subarrays/">子数组</a></li><li><a class="tocitem" href="../../devdocs/isbitsunionarrays/">isbits Union Optimizations</a></li><li><a class="tocitem" href="../../devdocs/sysimg/">System Image Building</a></li><li><a class="tocitem" href="../../devdocs/llvm/">Working with LLVM</a></li><li><a class="tocitem" href="../../devdocs/stdio/">printf() and stdio in the Julia runtime</a></li><li><a class="tocitem" href="../../devdocs/boundscheck/">边界检查</a></li><li><a class="tocitem" href="../../devdocs/locks/">Proper maintenance and care of multi-threading locks</a></li><li><a class="tocitem" href="../../devdocs/offset-arrays/">Arrays with custom indices</a></li><li><a class="tocitem" href="../../devdocs/require/">Module loading</a></li><li><a class="tocitem" href="../../devdocs/inference/">类型推导</a></li><li><a class="tocitem" href="../../devdocs/ssair/">Julia SSA-form IR</a></li><li><a class="tocitem" href="../../devdocs/gc-sa/">Static analyzer annotations for GC correctness in C code</a></li></ul></li><li><input class="collapse-toggle" id="menuitem-5-3" type="checkbox"/><label class="tocitem" for="menuitem-5-3"><span class="docs-label">Developing/debugging Julia's C code</span><i class="docs-chevron"></i></label><ul class="collapsed"><li><a class="tocitem" href="../../devdocs/backtraces/">报告和分析崩溃(段错误)</a></li><li><a class="tocitem" href="../../devdocs/debuggingtips/">gdb 调试提示</a></li><li><a class="tocitem" href="../../devdocs/valgrind/">在Julia中使用Valgrind</a></li><li><a class="tocitem" href="../../devdocs/sanitizers/">Sanitizer support</a></li></ul></li></ul></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><nav class="breadcrumb"><ul class="is-hidden-mobile"><li><a class="is-disabled">Base</a></li><li class="is-active"><a href>基本功能</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>基本功能</a></li></ul></nav><div class="docs-right"><a class="docs-edit-link" href="https://www.transifex.com/juliacn/base-zh_cn/translate/#zh_CN/basemd" title=" 完善 Transifex 上的翻译"><span class="docs-icon fab"></span><span class="docs-label is-hidden-touch"> 完善 Transifex 上的翻译</span></a><a class="docs-settings-button fas fa-cog" id="documenter-settings-button" href="#" title="设置"></a><a class="docs-sidebar-button fa fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a></div></header><article class="content" id="documenter-page"><h1 id="基本功能"><a class="docs-heading-anchor" href="#基本功能">基本功能</a><a id="基本功能-1"></a><a class="docs-heading-anchor-permalink" href="#基本功能" title="Permalink"></a></h1><h2 id="介绍"><a class="docs-heading-anchor" href="#介绍">介绍</a><a id="介绍-1"></a><a class="docs-heading-anchor-permalink" href="#介绍" title="Permalink"></a></h2><p>Julia Base 中包含一系列适用于科学及数值计算的函数和宏,但也可以用于通用编程,其它功能则由 Julia 生态圈中的各种库来提供。函数按主题划分如下:</p><p>一些通用的提示:</p><ul><li>可以通过 <code>Import Module</code> 导入想要使用的模块,并利用 <code>Module.fn(x)</code> 语句来实现对模块内函数的调用。</li><li>此外,<code>using Module</code> 语句会将名为 <code>Module</code> 的模块中的所有可调函数引入当前的命名空间。</li><li>按照约定,名字以感叹号(<code>!</code>)结尾的函数会改变其输入参数的内容。 一些函数同时拥有改变参数(例如 <code>sort!</code>)和不改变参数(<code>sort</code>)的版本</li></ul><p>The behaviors of <code>Base</code> and standard libraries are stable as defined in <a href="https://semver.org/">SemVer</a> only if they are documented; i.e., included in the <a href="https://docs.julialang.org/">Julia documentation</a> and not marked as unstable. See <a href="../../manual/faq/#man-api">API FAQ</a> for more information.</p><h2 id="Getting-Around"><a class="docs-heading-anchor" href="#Getting-Around">Getting Around</a><a id="Getting-Around-1"></a><a class="docs-heading-anchor-permalink" href="#Getting-Around" title="Permalink"></a></h2><article class="docstring"><header><a class="docstring-binding" id="Base.exit" href="#Base.exit"><code>Base.exit</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">exit(code=0)</code></pre><p>Stop the program with an exit code. The default exit code is zero, indicating that the program completed successfully. In an interactive session, <code>exit()</code> can be called with the keyboard shortcut <code>^D</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/initdefs.jl#L21-L27">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.atexit" href="#Base.atexit"><code>Base.atexit</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">atexit(f)</code></pre><p>Register a zero-argument function <code>f()</code> to be called at process exit. <code>atexit()</code> hooks are called in last in first out (LIFO) order and run before object finalizers.</p><p>Exit hooks are allowed to call <code>exit(n)</code>, in which case Julia will exit with exit code <code>n</code> (instead of the original exit code). If more than one exit hook calls <code>exit(n)</code>, then Julia will exit with the exit code corresponding to the last called exit hook that calls <code>exit(n)</code>. (Because exit hooks are called in LIFO order, "last called" is equivalent to "first registered".)</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/initdefs.jl#L354-L365">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.isinteractive" href="#Base.isinteractive"><code>Base.isinteractive</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">isinteractive() -> Bool</code></pre><p>Determine whether Julia is running an interactive session.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/initdefs.jl#L35-L39">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.summarysize" href="#Base.summarysize"><code>Base.summarysize</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">Base.summarysize(obj; exclude=Union{...}, chargeall=Union{...}) -> Int</code></pre><p>Compute the amount of memory, in bytes, used by all unique objects reachable from the argument.</p><p><strong>Keyword Arguments</strong></p><ul><li><code>exclude</code>: specifies the types of objects to exclude from the traversal.</li><li><code>chargeall</code>: specifies the types of objects to always charge the size of all of their fields, even if those fields would normally be excluded.</li></ul><p>See also <a href="#Base.sizeof-Tuple{Type}"><code>sizeof</code></a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> Base.summarysize(1.0)
8
julia> Base.summarysize(Ref(rand(100)))
848
julia> sizeof(Ref(rand(100)))
8</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/summarysize.jl#L11-L34">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.require" href="#Base.require"><code>Base.require</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">require(into::Module, module::Symbol)</code></pre><p>This function is part of the implementation of <a href="#using"><code>using</code></a> / <a href="#import"><code>import</code></a>, if a module is not already defined in <code>Main</code>. It can also be called directly to force reloading a module, regardless of whether it has been loaded before (for example, when interactively developing libraries).</p><p>Loads a source file, in the context of the <code>Main</code> module, on every active node, searching standard locations for files. <code>require</code> is considered a top-level operation, so it sets the current <code>include</code> path but does not use it to search for files (see help for <a href="#Base.include"><code>include</code></a>). This function is typically used to load library code, and is implicitly called by <code>using</code> to load packages.</p><p>When searching for files, <code>require</code> first looks for package code in the global array <a href="../constants/#Base.LOAD_PATH"><code>LOAD_PATH</code></a>. <code>require</code> is case-sensitive on all platforms, including those with case-insensitive filesystems like macOS and Windows.</p><p>For more details regarding code loading, see the manual sections on <a href="../../manual/modules/#modules">modules</a> and <a href="../../manual/distributed-computing/#code-availability">parallel computing</a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/loading.jl#L1122-L1142">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.compilecache" href="#Base.compilecache"><code>Base.compilecache</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">Base.compilecache(module::PkgId)</code></pre><p>Creates a precompiled cache file for a module and all of its dependencies. This can be used to reduce package load times. Cache files are stored in <code>DEPOT_PATH[1]/compiled</code>. See <a href="base/@ref">Module initialization and precompilation</a> for important notes.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/loading.jl#L1629-L1636">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.__precompile__" href="#Base.__precompile__"><code>Base.__precompile__</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">__precompile__(isprecompilable::Bool)</code></pre><p>Specify whether the file calling this function is precompilable, defaulting to <code>true</code>. If a module or file is <em>not</em> safely precompilable, it should call <code>__precompile__(false)</code> in order to throw an error if Julia attempts to precompile it.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/loading.jl#L1105-L1111">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.include" href="#Base.include"><code>Base.include</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">Base.include([mapexpr::Function,] [m::Module,] path::AbstractString)</code></pre><p>Evaluate the contents of the input source file in the global scope of module <code>m</code>. Every module (except those defined with <a href="#baremodule"><code>baremodule</code></a>) has its own definition of <code>include</code> omitting the <code>m</code> argument, which evaluates the file in that module. Returns the result of the last evaluated expression of the input file. During including, a task-local include path is set to the directory containing the file. Nested calls to <code>include</code> will search relative to that path. This function is typically used to load source interactively, or to combine files in packages that are broken into multiple source files.</p><p>The optional first argument <code>mapexpr</code> can be used to transform the included code before it is evaluated: for each parsed expression <code>expr</code> in <code>path</code>, the <code>include</code> function actually evaluates <code>mapexpr(expr)</code>. If it is omitted, <code>mapexpr</code> defaults to <a href="#Base.identity"><code>identity</code></a>.</p><div class="admonition is-compat"><header class="admonition-header">Julia 1.5</header><div class="admonition-body"><p>Julia 1.5 is required for passing the <code>mapexpr</code> argument.</p></div></div></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/loading.jl#L1457-L1474">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.MainInclude.include" href="#Base.MainInclude.include"><code>Base.MainInclude.include</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">include([mapexpr::Function,] path::AbstractString)</code></pre><p>Evaluate the contents of the input source file in the global scope of the containing module. Every module (except those defined with <code>baremodule</code>) has its own definition of <code>include</code>, which evaluates the file in that module. Returns the result of the last evaluated expression of the input file. During including, a task-local include path is set to the directory containing the file. Nested calls to <code>include</code> will search relative to that path. This function is typically used to load source interactively, or to combine files in packages that are broken into multiple source files. The argument <code>path</code> is normalized using <a href="../file/#Base.Filesystem.normpath"><code>normpath</code></a> which will resolve relative path tokens such as <code>..</code> and convert <code>/</code> to the appropriate path separator.</p><p>The optional first argument <code>mapexpr</code> can be used to transform the included code before it is evaluated: for each parsed expression <code>expr</code> in <code>path</code>, the <code>include</code> function actually evaluates <code>mapexpr(expr)</code>. If it is omitted, <code>mapexpr</code> defaults to <a href="#Base.identity"><code>identity</code></a>.</p><p>Use <a href="#Base.include"><code>Base.include</code></a> to evaluate a file into another module.</p><div class="admonition is-compat"><header class="admonition-header">Julia 1.5</header><div class="admonition-body"><p>Julia 1.5 is required for passing the <code>mapexpr</code> argument.</p></div></div></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/client.jl#L490-L511">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.include_string" href="#Base.include_string"><code>Base.include_string</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">include_string([mapexpr::Function,] m::Module, code::AbstractString, filename::AbstractString="string")</code></pre><p>Like <a href="#Base.include"><code>include</code></a>, except reads code from the given string rather than from a file.</p><p>The optional first argument <code>mapexpr</code> can be used to transform the included code before it is evaluated: for each parsed expression <code>expr</code> in <code>code</code>, the <code>include_string</code> function actually evaluates <code>mapexpr(expr)</code>. If it is omitted, <code>mapexpr</code> defaults to <a href="#Base.identity"><code>identity</code></a>.</p><div class="admonition is-compat"><header class="admonition-header">Julia 1.5</header><div class="admonition-body"><p>Julia 1.5 is required for passing the <code>mapexpr</code> argument.</p></div></div></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/loading.jl#L1398-L1409">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.include_dependency" href="#Base.include_dependency"><code>Base.include_dependency</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">include_dependency(path::AbstractString)</code></pre><p>In a module, declare that the file specified by <code>path</code> (relative or absolute) is a dependency for precompilation; that is, the module will need to be recompiled if this file changes.</p><p>This is only needed if your module depends on a file that is not used via <a href="#Base.include"><code>include</code></a>. It has no effect outside of compilation.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/loading.jl#L1080-L1089">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.which-Tuple{Any, Any}" href="#Base.which-Tuple{Any, Any}"><code>Base.which</code></a> — <span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia">which(f, types)</code></pre><p>Returns the method of <code>f</code> (a <code>Method</code> object) that would be called for arguments of the given <code>types</code>.</p><p>If <code>types</code> is an abstract type, then the method that would be called by <code>invoke</code> is returned.</p><p>See also: <a href="#Base.parentmodule"><code>parentmodule</code></a>, and <code>@which</code> and <code>@edit</code> in <a href="../../stdlib/InteractiveUtils/#man-interactive-utils"><code>InteractiveUtils</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L1399-L1407">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.methods" href="#Base.methods"><code>Base.methods</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">methods(f, [types], [module])</code></pre><p>Return the method table for <code>f</code>.</p><p>If <code>types</code> is specified, return an array of methods whose types match. If <code>module</code> is specified, return an array of methods defined in that module. A list of modules can also be specified as an array.</p><div class="admonition is-compat"><header class="admonition-header">Julia 1.4</header><div class="admonition-body"><p>At least Julia 1.4 is required for specifying a module.</p></div></div><p>See also: <a href="#Base.which-Tuple{Any, Any}"><code>which</code></a> and <code>@which</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L967-L980">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.@show" href="#Base.@show"><code>Base.@show</code></a> — <span class="docstring-category">Macro</span></header><section><div><pre><code class="language-julia">@show exs...</code></pre><p>Prints one or more expressions, and their results, to <code>stdout</code>, and returns the last result.</p><p>See also: <a href="../io-network/#Base.show-Tuple{IO, Any}"><code>show</code></a>, <a href="../math/#Base.:--Tuple{Any, Any}"><code>@info</code></a>, <a href="../io-network/#Base.println"><code>println</code></a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> x = @show 1+2
1 + 2 = 3
3
julia> @show x^2 x/2;
x ^ 2 = 9
x / 2 = 1.5</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/show.jl#L1025-L1042">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="ans" href="#ans"><code>ans</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">ans</code></pre><p>A variable referring to the last computed value, automatically set at the interactive prompt.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L1259-L1263">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.active_project" href="#Base.active_project"><code>Base.active_project</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">active_project()</code></pre><p>Return the path of the active <code>Project.toml</code> file. See also <a href="base/@ref"><code>Base.set_active_project</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/initdefs.jl#L285-L289">source</a></section></article><h2 id="Keywords"><a class="docs-heading-anchor" href="#Keywords">Keywords</a><a id="Keywords-1"></a><a class="docs-heading-anchor-permalink" href="#Keywords" title="Permalink"></a></h2><p>This is the list of reserved keywords in Julia: <code>baremodule</code>, <code>begin</code>, <code>break</code>, <code>catch</code>, <code>const</code>, <code>continue</code>, <code>do</code>, <code>else</code>, <code>elseif</code>, <code>end</code>, <code>export</code>, <code>false</code>, <code>finally</code>, <code>for</code>, <code>function</code>, <code>global</code>, <code>if</code>, <code>import</code>, <code>let</code>, <code>local</code>, <code>macro</code>, <code>module</code>, <code>quote</code>, <code>return</code>, <code>struct</code>, <code>true</code>, <code>try</code>, <code>using</code>, <code>while</code>. Those keywords are not allowed to be used as variable names.</p><p>The following two-word sequences are reserved: <code>abstract type</code>, <code>mutable struct</code>, <code>primitive type</code>. However, you can create variables with names: <code>abstract</code>, <code>mutable</code>, <code>primitive</code> and <code>type</code>.</p><p>Finally: <code>where</code> is parsed as an infix operator for writing parametric method and type definitions; <code>in</code> and <code>isa</code> are parsed as infix operators; and <code>outer</code> is parsed as a keyword when used to modify the scope of a variable in an iteration specification of a <code>for</code> loop or <code>generator</code> expression. Creation of variables named <code>where</code>, <code>in</code>, <code>isa</code> or <code>outer</code> is allowed though.</p><article class="docstring"><header><a class="docstring-binding" id="module" href="#module"><code>module</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">module</code></pre><p><code>module</code> declares a <a href="#Core.Module"><code>Module</code></a>, which is a separate global variable workspace. Within a module, you can control which names from other modules are visible (via importing), and specify which of your names are intended to be public (via exporting). Modules allow you to create top-level definitions without worrying about name conflicts when your code is used together with somebody else’s. See the <a href="../../manual/modules/#modules">manual section about modules</a> for more details.</p><p><strong>Examples</strong></p><pre><code class="language-julia">module Foo
import Base.show
export MyType, foo
struct MyType
x
end
bar(x) = 2x
foo(a::MyType) = bar(a.x) + 1
show(io::IO, a::MyType) = print(io, "MyType $(a.x)")
end</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L78-L103">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="export" href="#export"><code>export</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">export</code></pre><p><code>export</code> is used within modules to tell Julia which functions should be made available to the user. For example: <code>export foo</code> makes the name <code>foo</code> available when <a href="#using"><code>using</code></a> the module. See the <a href="../../manual/modules/#modules">manual section about modules</a> for details.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L52-L59">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="import" href="#import"><code>import</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">import</code></pre><p><code>import Foo</code> will load the module or package <code>Foo</code>. Names from the imported <code>Foo</code> module can be accessed with dot syntax (e.g. <code>Foo.foo</code> to access the name <code>foo</code>). See the <a href="../../manual/modules/#modules">manual section about modules</a> for details.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L42-L49">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="using" href="#using"><code>using</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">using</code></pre><p><code>using Foo</code> will load the module or package <code>Foo</code> and make its <a href="#export"><code>export</code></a>ed names available for direct use. Names can also be used via dot syntax (e.g. <code>Foo.foo</code> to access the name <code>foo</code>), whether they are <code>export</code>ed or not. See the <a href="../../manual/modules/#modules">manual section about modules</a> for details.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L32-L39">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="baremodule" href="#baremodule"><code>baremodule</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">baremodule</code></pre><p><code>baremodule</code> declares a module that does not contain <code>using Base</code> or local definitions of <a href="#Base.MainInclude.eval"><code>eval</code></a> and <a href="#Base.include"><code>include</code></a>. It does still import <code>Core</code>. In other words,</p><pre><code class="language-julia">module Mod
...
end</code></pre><p>is equivalent to</p><pre><code class="language-julia">baremodule Mod
using Base
eval(x) = Core.eval(Mod, x)
include(p) = Base.include(Mod, p)
...
end</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L129-L157">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="function" href="#function"><code>function</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">function</code></pre><p>Functions are defined with the <code>function</code> keyword:</p><pre><code class="language-julia">function add(a, b)
return a + b
end</code></pre><p>Or the short form notation:</p><pre><code class="language-julia">add(a, b) = a + b</code></pre><p>The use of the <a href="#return"><code>return</code></a> keyword is exactly the same as in other languages, but is often optional. A function without an explicit <code>return</code> statement will return the last expression in the function body.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L611-L630">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="macro" href="#macro"><code>macro</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">macro</code></pre><p><code>macro</code> defines a method for inserting generated code into a program. A macro maps a sequence of argument expressions to a returned expression, and the resulting expression is substituted directly into the program at the point where the macro is invoked. Macros are a way to run generated code without calling <a href="#Base.MainInclude.eval"><code>eval</code></a>, since the generated code instead simply becomes part of the surrounding program. Macro arguments may include expressions, literal values, and symbols. Macros can be defined for variable number of arguments (varargs), but do not accept keyword arguments. Every macro also implicitly gets passed the arguments <code>__source__</code>, which contains the line number and file name the macro is called from, and <code>__module__</code>, which is the module the macro is expanded in.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> macro sayhello(name)
return :( println("Hello, ", $name, "!") )
end
@sayhello (macro with 1 method)
julia> @sayhello "Charlie"
Hello, Charlie!
julia> macro saylots(x...)
return :( println("Say: ", $(x...)) )
end
@saylots (macro with 1 method)
julia> @saylots "hey " "there " "friend"
Say: hey there friend</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L178-L211">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="return" href="#return"><code>return</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">return</code></pre><p><code>return x</code> causes the enclosing function to exit early, passing the given value <code>x</code> back to its caller. <code>return</code> by itself with no value is equivalent to <code>return nothing</code> (see <a href="../constants/#Core.nothing"><code>nothing</code></a>).</p><pre><code class="language-julia">function compare(a, b)
a == b && return "equal to"
a < b ? "less than" : "greater than"
end</code></pre><p>In general you can place a <code>return</code> statement anywhere within a function body, including within deeply nested loops or conditionals, but be careful with <code>do</code> blocks. For example:</p><pre><code class="language-julia">function test1(xs)
for x in xs
iseven(x) && return 2x
end
end
function test2(xs)
map(xs) do x
iseven(x) && return 2x
x
end
end</code></pre><p>In the first example, the return breaks out of <code>test1</code> as soon as it hits an even number, so <code>test1([5,6,7])</code> returns <code>12</code>.</p><p>You might expect the second example to behave the same way, but in fact the <code>return</code> there only breaks out of the <em>inner</em> function (inside the <code>do</code> block) and gives a value back to <code>map</code>. <code>test2([5,6,7])</code> then returns <code>[5,12,7]</code>.</p><p>When used in a top-level expression (i.e. outside any function), <code>return</code> causes the entire current top-level expression to terminate early.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L659-L699">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="do" href="#do"><code>do</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">do</code></pre><p>Create an anonymous function and pass it as the first argument to a function call. For example:</p><pre><code class="language-julia">map(1:10) do x
2x
end</code></pre><p>is equivalent to <code>map(x->2x, 1:10)</code>.</p><p>Use multiple arguments like so:</p><pre><code class="language-julia">map(1:10, 11:20) do x, y
x + y
end</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L926-L948">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="begin" href="#begin"><code>begin</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">begin</code></pre><p><code>begin...end</code> denotes a block of code.</p><pre><code class="language-julia">begin
println("Hello, ")
println("World!")
end</code></pre><p>Usually <code>begin</code> will not be necessary, since keywords such as <a href="#function"><code>function</code></a> and <a href="#let"><code>let</code></a> implicitly begin blocks of code. See also <a href="#;"><code>;</code></a>.</p><p><code>begin</code> may also be used when indexing to represent the first index of a collection or the first index of a dimension of an array.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> A = [1 2; 3 4]
2×2 Array{Int64,2}:
1 2
3 4
julia> A[begin, :]
2-element Array{Int64,1}:
1
2</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L1108-L1138">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="end" href="#end"><code>end</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">end</code></pre><p><code>end</code> marks the conclusion of a block of expressions, for example <a href="#module"><code>module</code></a>, <a href="#struct"><code>struct</code></a>, <a href="#mutable struct"><code>mutable struct</code></a>, <a href="#begin"><code>begin</code></a>, <a href="#let"><code>let</code></a>, <a href="#for"><code>for</code></a> etc.</p><p><code>end</code> may also be used when indexing to represent the last index of a collection or the last index of a dimension of an array.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> A = [1 2; 3 4]
2×2 Array{Int64, 2}:
1 2
3 4
julia> A[end, :]
2-element Array{Int64, 1}:
3
4</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L797-L819">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="let" href="#let"><code>let</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">let</code></pre><p><code>let</code> statements create a new hard scope block and introduce new variable bindings each time they run. Whereas assignments might reassign a new value to an existing value location, <code>let</code> always creates a new location. This difference is only detectable in the case of variables that outlive their scope via closures. The <code>let</code> syntax accepts a comma-separated series of assignments and variable names:</p><pre><code class="language-julia">let var1 = value1, var2, var3 = value3
code
end</code></pre><p>The assignments are evaluated in order, with each right-hand side evaluated in the scope before the new variable on the left-hand side has been introduced. Therefore it makes sense to write something like <code>let x = x</code>, since the two <code>x</code> variables are distinct and have separate storage.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L430-L449">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="if" href="#if"><code>if</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">if/elseif/else</code></pre><p><code>if</code>/<code>elseif</code>/<code>else</code> performs conditional evaluation, which allows portions of code to be evaluated or not evaluated depending on the value of a boolean expression. Here is the anatomy of the <code>if</code>/<code>elseif</code>/<code>else</code> conditional syntax:</p><pre><code class="language-julia">if x < y
println("x is less than y")
elseif x > y
println("x is greater than y")
else
println("x is equal to y")
end</code></pre><p>If the condition expression <code>x < y</code> is true, then the corresponding block is evaluated; otherwise the condition expression <code>x > y</code> is evaluated, and if it is true, the corresponding block is evaluated; if neither expression is true, the <code>else</code> block is evaluated. The <code>elseif</code> and <code>else</code> blocks are optional, and as many <code>elseif</code> blocks as desired can be used.</p><p>In contrast to some other languages conditions must be of type <code>Bool</code>. It does not suffice for conditions to be convertible to <code>Bool</code>.</p><pre><code class="language-julia-repl">julia> if 1 end
ERROR: TypeError: non-boolean (Int64) used in boolean context</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L702-L730">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="for" href="#for"><code>for</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">for</code></pre><p><code>for</code> loops repeatedly evaluate a block of statements while iterating over a sequence of values.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> for i in [1, 4, 0]
println(i)
end
1
4
0</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L755-L770">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="while" href="#while"><code>while</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">while</code></pre><p><code>while</code> loops repeatedly evaluate a conditional expression, and continue evaluating the body of the while loop as long as the expression remains true. If the condition expression is false when the while loop is first reached, the body is never evaluated.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> i = 1
1
julia> while i < 5
println(i)
global i += 1
end
1
2
3
4</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L773-L794">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="break" href="#break"><code>break</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">break</code></pre><p>Break out of a loop immediately.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> i = 0
0
julia> while true
global i += 1
i > 5 && break
println(i)
end
1
2
3
4
5</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L884-L905">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="continue" href="#continue"><code>continue</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">continue</code></pre><p>Skip the rest of the current loop iteration.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> for i = 1:6
iseven(i) && continue
println(i)
end
1
3
5</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L908-L923">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="try" href="#try"><code>try</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">try/catch</code></pre><p>A <code>try</code>/<code>catch</code> statement allows intercepting errors (exceptions) thrown by <a href="#Core.throw"><code>throw</code></a> so that program execution can continue. For example, the following code attempts to write a file, but warns the user and proceeds instead of terminating execution if the file cannot be written:</p><pre><code class="language-julia">try
open("/danger", "w") do f
println(f, "Hello")
end
catch
@warn "Could not write file."
end</code></pre><p>or, when the file cannot be read into a variable:</p><pre><code class="language-julia">lines = try
open("/danger", "r") do f
readlines(f)
end
catch
@warn "File not found."
end</code></pre><p>The syntax <code>catch e</code> (where <code>e</code> is any variable) assigns the thrown exception object to the given variable within the <code>catch</code> block.</p><p>The power of the <code>try</code>/<code>catch</code> construct lies in the ability to unwind a deeply nested computation immediately to a much higher level in the stack of calling functions.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L822-L857">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="finally" href="#finally"><code>finally</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">finally</code></pre><p>Run some code when a given block of code exits, regardless of how it exits. For example, here is how we can guarantee that an opened file is closed:</p><pre><code class="language-julia">f = open("file")
try
operate_on_file(f)
finally
close(f)
end</code></pre><p>When control leaves the <a href="#try"><code>try</code></a> block (for example, due to a <a href="#return"><code>return</code></a>, or just finishing normally), <a href="../io-network/#Base.close"><code>close(f)</code></a> will be executed. If the <code>try</code> block exits due to an exception, the exception will continue propagating. A <code>catch</code> block may be combined with <code>try</code> and <code>finally</code> as well. In this case the <code>finally</code> block will run after <code>catch</code> has handled the error.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L860-L881">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="quote" href="#quote"><code>quote</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">quote</code></pre><p><code>quote</code> creates multiple expression objects in a block without using the explicit <a href="#Core.Expr"><code>Expr</code></a> constructor. For example:</p><pre><code class="language-julia">ex = quote
x = 1
y = 2
x + y
end</code></pre><p>Unlike the other means of quoting, <code>:( ... )</code>, this form introduces <code>QuoteNode</code> elements to the expression tree, which must be considered when directly manipulating the tree. For other purposes, <code>:( ... )</code> and <code>quote .. end</code> blocks are treated identically.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L452-L468">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="local" href="#local"><code>local</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">local</code></pre><p><code>local</code> introduces a new local variable. See the <a href="../../manual/variables-and-scoping/#scope-of-variables">manual section on variable scoping</a> for more information.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> function foo(n)
x = 0
for i = 1:n
local x # introduce a loop-local x
x = i
end
x
end
foo (generic function with 1 method)
julia> foo(10)
0</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L232-L253">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="global" href="#global"><code>global</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">global</code></pre><p><code>global x</code> makes <code>x</code> in the current scope and its inner scopes refer to the global variable of that name. See the <a href="../../manual/variables-and-scoping/#scope-of-variables">manual section on variable scoping</a> for more information.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> z = 3
3
julia> function foo()
global z = 6 # use the z variable defined outside foo
end
foo (generic function with 1 method)
julia> foo()
6
julia> z
6</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L256-L279">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="const" href="#const"><code>const</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">const</code></pre><p><code>const</code> is used to declare global variables whose values will not change. In almost all code (and particularly performance sensitive code) global variables should be declared constant in this way.</p><pre><code class="language-julia">const x = 5</code></pre><p>Multiple variables can be declared within a single <code>const</code>:</p><pre><code class="language-julia">const y, z = 7, 11</code></pre><p>Note that <code>const</code> only applies to one <code>=</code> operation, therefore <code>const x = y = 1</code> declares <code>x</code> to be constant but not <code>y</code>. On the other hand, <code>const x = const y = 1</code> declares both <code>x</code> and <code>y</code> constant.</p><p>Note that "constant-ness" does not extend into mutable containers; only the association between a variable and its value is constant. If <code>x</code> is an array or dictionary (for example) you can still modify, add, or remove elements.</p><p>In some cases changing the value of a <code>const</code> variable gives a warning instead of an error. However, this can produce unpredictable behavior or corrupt the state of your program, and so should be avoided. This feature is intended only for convenience during interactive use.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L579-L608">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="struct" href="#struct"><code>struct</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">struct</code></pre><p>The most commonly used kind of type in Julia is a struct, specified as a name and a set of fields.</p><pre><code class="language-julia">struct Point
x
y
end</code></pre><p>Fields can have type restrictions, which may be parameterized:</p><pre><code class="language-julia">struct Point{X}
x::X
y::Float64
end</code></pre><p>A struct can also declare an abstract super type via <code><:</code> syntax:</p><pre><code class="language-julia">struct Point <: AbstractPoint
x
y
end</code></pre><p><code>struct</code>s are immutable by default; an instance of one of these types cannot be modified after construction. Use <a href="#mutable struct"><code>mutable struct</code></a> instead to declare a type whose instances can be modified.</p><p>See the manual section on <a href="base/@ref">Composite Types</a> for more details, such as how to define constructors.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L1141-L1178">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="mutable struct" href="#mutable struct"><code>mutable struct</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">mutable struct</code></pre><p><code>mutable struct</code> is similar to <a href="#struct"><code>struct</code></a>, but additionally allows the fields of the type to be set after construction. See the manual section on <a href="base/@ref">Composite Types</a> for more information.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L1181-L1187">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="abstract type" href="#abstract type"><code>abstract type</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">abstract type</code></pre><p><code>abstract type</code> declares a type that cannot be instantiated, and serves only as a node in the type graph, thereby describing sets of related concrete types: those concrete types which are their descendants. Abstract types form the conceptual hierarchy which makes Julia’s type system more than just a collection of object implementations. For example:</p><pre><code class="language-julia">abstract type Number end
abstract type Real <: Number end</code></pre><p><a href="../numbers/#Core.Number"><code>Number</code></a> has no supertype, whereas <a href="../numbers/#Core.Real"><code>Real</code></a> is an abstract subtype of <code>Number</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L62-L75">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="primitive type" href="#primitive type"><code>primitive type</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">primitive type</code></pre><p><code>primitive type</code> declares a concrete type whose data consists only of a series of bits. Classic examples of primitive types are integers and floating-point values. Some example built-in primitive type declarations:</p><pre><code class="language-julia">primitive type Char 32 end
primitive type Bool <: Integer 8 end</code></pre><p>The number after the name indicates how many bits of storage the type requires. Currently, only sizes that are multiples of 8 bits are supported. The <a href="../numbers/#Core.Bool"><code>Bool</code></a> declaration shows how a primitive type can be optionally declared to be a subtype of some supertype.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L160-L175">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="where" href="#where"><code>where</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">where</code></pre><p>The <code>where</code> keyword creates a type that is an iterated union of other types, over all values of some variable. For example <code>Vector{T} where T<:Real</code> includes all <a href="../arrays/#Base.Vector"><code>Vector</code></a>s where the element type is some kind of <code>Real</code> number.</p><p>The variable bound defaults to <a href="#Core.Any"><code>Any</code></a> if it is omitted:</p><pre><code class="language-julia">Vector{T} where T # short for `where T<:Any`</code></pre><p>Variables can also have lower bounds:</p><pre><code class="language-julia">Vector{T} where T>:Int
Vector{T} where Int<:T<:Real</code></pre><p>There is also a concise syntax for nested <code>where</code> expressions. For example, this:</p><pre><code class="language-julia">Pair{T, S} where S<:Array{T} where T<:Number</code></pre><p>can be shortened to:</p><pre><code class="language-julia">Pair{T, S} where {T<:Number, S<:Array{T}}</code></pre><p>This form is often found on method signatures.</p><p>Note that in this form, the variables are listed outermost-first. This matches the order in which variables are substituted when a type is "applied" to parameter values using the syntax <code>T{p1, p2, ...}</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L1200-L1233">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="..." href="#..."><code>...</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">...</code></pre><p>The "splat" operator, <code>...</code>, represents a sequence of arguments. <code>...</code> can be used in function definitions, to indicate that the function accepts an arbitrary number of arguments. <code>...</code> can also be used to apply a function to a sequence of arguments.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> add(xs...) = reduce(+, xs)
add (generic function with 1 method)
julia> add(1, 2, 3, 4, 5)
15
julia> add([1, 2, 3]...)
6
julia> add(7, 1:100..., 1000:1100...)
111107</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L951-L973">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id=";" href="#;"><code>;</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">;</code></pre><p><code>;</code> has a similar role in Julia as in many C-like languages, and is used to delimit the end of the previous statement.</p><p><code>;</code> is not necessary at the end of a line, but can be used to separate statements on a single line or to join statements into a single expression.</p><p>Adding <code>;</code> at the end of a line in the REPL will suppress printing the result of that expression.</p><p>In function declarations, and optionally in calls, <code>;</code> separates regular arguments from keywords.</p><p>While constructing arrays, if the arguments inside the square brackets are separated by <code>;</code> then their contents are vertically concatenated together.</p><p>In the standard REPL, typing <code>;</code> on an empty line will switch to shell mode.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> function foo()
x = "Hello, "; x *= "World!"
return x
end
foo (generic function with 1 method)
julia> bar() = (x = "Hello, Mars!"; return x)
bar (generic function with 1 method)
julia> foo();
julia> bar()
"Hello, Mars!"
julia> function plot(x, y; style="solid", width=1, color="black")
###
end
julia> [1 2; 3 4]
2×2 Matrix{Int64}:
1 2
3 4
julia> ; # upon typing ;, the prompt changes (in place) to: shell>
shell> echo hello
hello</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L976-L1023">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="=" href="#="><code>=</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">=</code></pre><p><code>=</code> is the assignment operator.</p><ul><li>For variable <code>a</code> and expression <code>b</code>, <code>a = b</code> makes <code>a</code> refer to the value of <code>b</code>.</li><li>For functions <code>f(x)</code>, <code>f(x) = x</code> defines a new function constant <code>f</code>, or adds a new method to <code>f</code> if <code>f</code> is already defined; this usage is equivalent to <code>function f(x); x; end</code>.</li><li><code>a[i] = v</code> calls <a href="../collections/#Base.setindex!"><code>setindex!</code></a><code>(a,v,i)</code>.</li><li><code>a.b = c</code> calls <a href="#Base.setproperty!"><code>setproperty!</code></a><code>(a,:b,c)</code>.</li><li>Inside a function call, <code>f(a=b)</code> passes <code>b</code> as the value of keyword argument <code>a</code>.</li><li>Inside parentheses with commas, <code>(a=1,)</code> constructs a <a href="#Core.NamedTuple"><code>NamedTuple</code></a>.</li></ul><p><strong>Examples</strong></p><p>Assigning <code>a</code> to <code>b</code> does not create a copy of <code>b</code>; instead use <a href="#Base.copy"><code>copy</code></a> or <a href="#Base.deepcopy"><code>deepcopy</code></a>.</p><pre><code class="language-julia-repl">julia> b = [1]; a = b; b[1] = 2; a
1-element Array{Int64, 1}:
2
julia> b = [1]; a = copy(b); b[1] = 2; a
1-element Array{Int64, 1}:
1
</code></pre><p>Collections passed to functions are also not copied. Functions can modify (mutate) the contents of the objects their arguments refer to. (The names of functions which do this are conventionally suffixed with '!'.)</p><pre><code class="language-julia-repl">julia> function f!(x); x[:] .+= 1; end
f! (generic function with 1 method)
julia> a = [1]; f!(a); a
1-element Array{Int64, 1}:
2
</code></pre><p>Assignment can operate on multiple variables in parallel, taking values from an iterable:</p><pre><code class="language-julia-repl">julia> a, b = 4, 5
(4, 5)
julia> a, b = 1:3
1:3
julia> a, b
(1, 2)
</code></pre><p>Assignment can operate on multiple variables in series, and will return the value of the right-hand-most expression:</p><pre><code class="language-julia-repl">julia> a = [1]; b = [2]; c = [3]; a = b = c
1-element Array{Int64, 1}:
3
julia> b[1] = 2; a, b, c
([2], [2], [2])
</code></pre><p>Assignment at out-of-bounds indices does not grow a collection. If the collection is a <a href="../arrays/#Base.Vector"><code>Vector</code></a> it can instead be grown with <a href="../collections/#Base.push!"><code>push!</code></a> or <a href="../collections/#Base.append!"><code>append!</code></a>.</p><pre><code class="language-julia-repl">julia> a = [1, 1]; a[3] = 2
ERROR: BoundsError: attempt to access 2-element Array{Int64, 1} at index [3]
[...]
julia> push!(a, 2, 3)
4-element Array{Int64, 1}:
1
1
2
3
</code></pre><p>Assigning <code>[]</code> does not eliminate elements from a collection; instead use <a href="../collections/#Base.filter!"><code>filter!</code></a>.</p><pre><code class="language-julia-repl">julia> a = collect(1:3); a[a .<= 1] = []
ERROR: DimensionMismatch: tried to assign 0 elements to 1 destinations
[...]
julia> filter!(x -> x > 1, a) # in-place & thus more efficient than a = a[a .> 1]
2-element Array{Int64, 1}:
2
3
</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L295-L377">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="?:" href="#?:"><code>?:</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">a ? b : c</code></pre><p>Short form for conditionals; read "if <code>a</code>, evaluate <code>b</code> otherwise evaluate <code>c</code>". Also known as the <a href="https://en.wikipedia.org/wiki/%3F:">ternary operator</a>.</p><p>This syntax is equivalent to <code>if a; b else c end</code>, but is often used to emphasize the value <code>b</code>-or-<code>c</code> which is being used as part of a larger expression, rather than the side effects that evaluating <code>b</code> or <code>c</code> may have.</p><p>See the manual section on <a href="../../manual/control-flow/#man-conditional-evaluation">control flow</a> for more details.</p><p><strong>Examples</strong></p><pre><code class="language-none">julia> x = 1; y = 2;
julia> x > y ? println("x is larger") : println("y is larger")
y is larger</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L733-L752">source</a></section></article><h2 id="Standard-Modules"><a class="docs-heading-anchor" href="#Standard-Modules">Standard Modules</a><a id="Standard-Modules-1"></a><a class="docs-heading-anchor-permalink" href="#Standard-Modules" title="Permalink"></a></h2><div class="admonition is-warning"><header class="admonition-header">Missing docstring.</header><div class="admonition-body"><p>Missing docstring for <code>Main</code>. Check Documenter's build log for details.</p></div></div><article class="docstring"><header><a class="docstring-binding" id="Core" href="#Core"><code>Core</code></a> — <span class="docstring-category">Module</span></header><section><div><pre><code class="language-julia">Core</code></pre><p><code>Core</code> is the module that contains all identifiers considered "built in" to the language, i.e. part of the core language and not libraries. Every module implicitly specifies <code>using Core</code>, since you can't do anything without those definitions.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L2826-L2830">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base" href="#Base"><code>Base</code></a> — <span class="docstring-category">Module</span></header><section><div><pre><code class="language-julia">Base</code></pre><p>The base library of Julia. <code>Base</code> is a module that contains basic functionality (the contents of <code>base/</code>). All modules implicitly contain <code>using Base</code>, since this is needed in the vast majority of cases.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L2844-L2848">source</a></section></article><h2 id="Base-Submodules"><a class="docs-heading-anchor" href="#Base-Submodules">Base Submodules</a><a id="Base-Submodules-1"></a><a class="docs-heading-anchor-permalink" href="#Base-Submodules" title="Permalink"></a></h2><article class="docstring"><header><a class="docstring-binding" id="Base.Broadcast" href="#Base.Broadcast"><code>Base.Broadcast</code></a> — <span class="docstring-category">Module</span></header><section><div><pre><code class="language-julia">Base.Broadcast</code></pre><p>Module containing the broadcasting implementation.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/broadcast.jl#L3-L7">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Docs" href="#Base.Docs"><code>Base.Docs</code></a> — <span class="docstring-category">Module</span></header><section><div><pre><code class="language-julia">Docs</code></pre><p>The <code>Docs</code> module provides the <code>@doc</code> macro which can be used to set and retrieve documentation metadata for Julia objects.</p><p>Please see the manual section on <a href="../../manual/documentation/#man-documentation">documentation</a> for more information.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/Docs.jl#L3-L11">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Iterators" href="#Base.Iterators"><code>Base.Iterators</code></a> — <span class="docstring-category">Module</span></header><section><div><p>Methods for working with Iterators.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/iterators.jl#L3-L5">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Libc" href="#Base.Libc"><code>Base.Libc</code></a> — <span class="docstring-category">Module</span></header><section><div><p>Interface to libc, the C standard library.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/libc.jl#L4-L6">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Meta" href="#Base.Meta"><code>Base.Meta</code></a> — <span class="docstring-category">Module</span></header><section><div><p>Convenience functions for metaprogramming.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/meta.jl#L3-L5">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.StackTraces" href="#Base.StackTraces"><code>Base.StackTraces</code></a> — <span class="docstring-category">Module</span></header><section><div><p>Tools for collecting and manipulating stack traces. Mainly used for building errors.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/stacktraces.jl#L3-L5">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Sys" href="#Base.Sys"><code>Base.Sys</code></a> — <span class="docstring-category">Module</span></header><section><div><p>Provide methods for retrieving information about hardware and the operating system.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/sysinfo.jl#L4-L6">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Threads" href="#Base.Threads"><code>Base.Threads</code></a> — <span class="docstring-category">Module</span></header><section><div><p>Multithreading support.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/threads.jl#L3-L5">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.GC" href="#Base.GC"><code>Base.GC</code></a> — <span class="docstring-category">Module</span></header><section><div><pre><code class="language-julia">Base.GC</code></pre><p>Module with garbage collection utilities.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/gcutils.jl#L70-L74">source</a></section></article><h2 id="All-Objects"><a class="docs-heading-anchor" href="#All-Objects">All Objects</a><a id="All-Objects-1"></a><a class="docs-heading-anchor-permalink" href="#All-Objects" title="Permalink"></a></h2><article class="docstring"><header><a class="docstring-binding" id="Core.:===" href="#Core.:==="><code>Core.:===</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">===(x,y) -> Bool
≡(x,y) -> Bool</code></pre><p>Determine whether <code>x</code> and <code>y</code> are identical, in the sense that no program could distinguish them. First the types of <code>x</code> and <code>y</code> are compared. If those are identical, mutable objects are compared by address in memory and immutable objects (such as numbers) are compared by contents at the bit level. This function is sometimes called "egal". It always returns a <code>Bool</code> value.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> a = [1, 2]; b = [1, 2];
julia> a == b
true
julia> a === b
false
julia> a === a
true</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/operators.jl#L285-L308">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.isa" href="#Core.isa"><code>Core.isa</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">isa(x, type) -> Bool</code></pre><p>Determine whether <code>x</code> is of the given <code>type</code>. Can also be used as an infix operator, e.g. <code>x isa type</code>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> isa(1, Int)
true
julia> isa(1, Matrix)
false
julia> isa(1, Char)
false
julia> isa(1, Number)
true
julia> 1 isa Number
true</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L1731-L1754">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.isequal" href="#Base.isequal"><code>Base.isequal</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">isequal(x, y)</code></pre><p>Similar to <a href="../math/#Base.:=="><code>==</code></a>, except for the treatment of floating point numbers and of missing values. <code>isequal</code> treats all floating-point <code>NaN</code> values as equal to each other, treats <code>-0.0</code> as unequal to <code>0.0</code>, and <a href="#Base.missing"><code>missing</code></a> as equal to <code>missing</code>. Always returns a <code>Bool</code> value.</p><p><code>isequal</code> is an equivalence relation - it is reflexive (<code>===</code> implies <code>isequal</code>), symmetric (<code>isequal(a, b)</code> implies <code>isequal(b, a)</code>) and transitive (<code>isequal(a, b)</code> and <code>isequal(b, c)</code> implies <code>isequal(a, c)</code>).</p><p><strong>Implementation</strong></p><p>The default implementation of <code>isequal</code> calls <code>==</code>, so a type that does not involve floating-point values generally only needs to define <code>==</code>.</p><p><code>isequal</code> is the comparison function used by hash tables (<code>Dict</code>). <code>isequal(x,y)</code> must imply that <code>hash(x) == hash(y)</code>.</p><p>This typically means that types for which a custom <code>==</code> or <code>isequal</code> method exists must implement a corresponding <a href="#Base.hash"><code>hash</code></a> method (and vice versa). Collections typically implement <code>isequal</code> by calling <code>isequal</code> recursively on all contents.</p><p>Furthermore, <code>isequal</code> is linked with <a href="#Base.isless"><code>isless</code></a>, and they work together to define a fixed total ordering, where exactly one of <code>isequal(x, y)</code>, <code>isless(x, y)</code>, or <code>isless(y, x)</code> must be <code>true</code> (and the other two <code>false</code>).</p><p>Scalar types generally do not need to implement <code>isequal</code> separate from <code>==</code>, unless they represent floating-point numbers amenable to a more efficient implementation than that provided as a generic fallback (based on <code>isnan</code>, <code>signbit</code>, and <code>==</code>).</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> isequal([1., NaN], [1., NaN])
true
julia> [1., NaN] == [1., NaN]
false
julia> 0.0 == -0.0
true
julia> isequal(0.0, -0.0)
false
julia> missing == missing
missing
julia> isequal(missing, missing)
true</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/operators.jl#L88-L139">source</a></section><section><div><pre><code class="language-none">isequal(x)</code></pre><p>Create a function that compares its argument to <code>x</code> using <a href="#Base.isequal"><code>isequal</code></a>, i.e. a function equivalent to <code>y -> isequal(y, x)</code>.</p><p>The returned function is of type <code>Base.Fix2{typeof(isequal)}</code>, which can be used to implement specialized methods.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/operators.jl#L1115-L1123">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.isless" href="#Base.isless"><code>Base.isless</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">isless(x, y)</code></pre><p>Test whether <code>x</code> is less than <code>y</code>, according to a fixed total order (defined together with <a href="#Base.isequal"><code>isequal</code></a>). <code>isless</code> is not defined on all pairs of values <code>(x, y)</code>. However, if it is defined, it is expected to satisfy the following:</p><ul><li>If <code>isless(x, y)</code> is defined, then so is <code>isless(y, x)</code> and <code>isequal(x, y)</code>, and exactly one of those three yields <code>true</code>.</li><li>The relation defined by <code>isless</code> is transitive, i.e., <code>isless(x, y) && isless(y, z)</code> implies <code>isless(x, z)</code>.</li></ul><p>Values that are normally unordered, such as <code>NaN</code>, are ordered after regular values. <a href="#Base.missing"><code>missing</code></a> values are ordered last.</p><p>This is the default comparison used by <a href="../sort/#Base.sort"><code>sort</code></a>.</p><p><strong>Implementation</strong></p><p>Non-numeric types with a total order should implement this function. Numeric types only need to implement it if they have special values such as <code>NaN</code>. Types with a partial order should implement <a href="../math/#Base.:<"><code><</code></a>. See the documentation on <a href="../sort/#Alternate-orderings">Alternate orderings</a> for how to define alternate ordering methods that can be used in sorting and related functions.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> isless(1, 3)
true
julia> isless("Red", "Blue")
false</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/operators.jl#L149-L181">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.ifelse" href="#Base.ifelse"><code>Base.ifelse</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">ifelse(condition::Bool, x, y)</code></pre><p>Return <code>x</code> if <code>condition</code> is <code>true</code>, otherwise return <code>y</code>. This differs from <code>?</code> or <code>if</code> in that it is an ordinary function, so all the arguments are evaluated first. In some cases, using <code>ifelse</code> instead of an <code>if</code> statement can eliminate the branch in generated code and provide higher performance in tight loops.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> ifelse(1 > 2, 1, 2)
2</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/essentials.jl#L475-L488">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.typeassert" href="#Core.typeassert"><code>Core.typeassert</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">typeassert(x, type)</code></pre><p>Throw a <a href="#Core.TypeError"><code>TypeError</code></a> unless <code>x isa type</code>. The syntax <code>x::type</code> calls this function.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> typeassert(2.5, Int)
ERROR: TypeError: in typeassert, expected Int64, got a value of type Float64
Stacktrace:
[...]</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L2673-L2686">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.typeof" href="#Core.typeof"><code>Core.typeof</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">typeof(x)</code></pre><p>Get the concrete type of <code>x</code>.</p><p>See also <a href="../collections/#Base.eltype"><code>eltype</code></a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> a = 1//2;
julia> typeof(a)
Rational{Int64}
julia> M = [1 2; 3.5 4];
julia> typeof(M)
Matrix{Float64} (alias for Array{Float64, 2})</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L2054-L2073">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.tuple" href="#Core.tuple"><code>Core.tuple</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">tuple(xs...)</code></pre><p>Construct a tuple of the given objects.</p><p>See also <a href="#Core.Tuple"><code>Tuple</code></a>, <a href="#Core.NamedTuple"><code>NamedTuple</code></a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> tuple(1, 'b', pi)
(1, 'b', π)
julia> ans === (1, 'b', π)
true
julia> Tuple(Real[1, 2, pi]) # takes a collection
(1, 2, π)</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L1922-L1940">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.ntuple" href="#Base.ntuple"><code>Base.ntuple</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">ntuple(f::Function, n::Integer)</code></pre><p>Create a tuple of length <code>n</code>, computing each element as <code>f(i)</code>, where <code>i</code> is the index of the element.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> ntuple(i -> 2*i, 4)
(2, 4, 6, 8)</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/ntuple.jl#L5-L16">source</a></section><section><div><pre><code class="language-none">ntuple(f, ::Val{N})</code></pre><p>Create a tuple of length <code>N</code>, computing each element as <code>f(i)</code>, where <code>i</code> is the index of the element. By taking a <code>Val(N)</code> argument, it is possible that this version of ntuple may generate more efficient code than the version taking the length as an integer. But <code>ntuple(f, N)</code> is preferable to <code>ntuple(f, Val(N))</code> in cases where <code>N</code> cannot be determined at compile time.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> ntuple(i -> 2*i, Val(4))
(2, 4, 6, 8)</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/ntuple.jl#L52-L68">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.objectid" href="#Base.objectid"><code>Base.objectid</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">objectid(x) -> UInt</code></pre><p>Get a hash value for <code>x</code> based on object identity. <code>objectid(x)==objectid(y)</code> if <code>x === y</code>.</p><p>See also <a href="#Base.hash"><code>hash</code></a>, <a href="../collections/#Base.IdDict"><code>IdDict</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L333-L339">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.hash" href="#Base.hash"><code>Base.hash</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">hash(x[, h::UInt]) -> UInt</code></pre><p>Compute an integer hash code such that <code>isequal(x,y)</code> implies <code>hash(x)==hash(y)</code>. The optional second argument <code>h</code> is a hash code to be mixed with the result.</p><p>New types should implement the 2-argument form, typically by calling the 2-argument <code>hash</code> method recursively in order to mix hashes of the contents with each other (and with <code>h</code>). Typically, any type that implements <code>hash</code> should also implement its own <a href="../math/#Base.:=="><code>==</code></a> (hence <a href="#Base.isequal"><code>isequal</code></a>) to guarantee the property mentioned above. Types supporting subtraction (operator <code>-</code>) should also implement <a href="#Base.widen"><code>widen</code></a>, which is required to hash values inside heterogeneous arrays.</p><p>See also: <a href="#Base.objectid"><code>objectid</code></a>, <a href="../collections/#Base.Dict"><code>Dict</code></a>, <a href="../collections/#Base.Set"><code>Set</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/hashing.jl#L5-L19">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.finalizer" href="#Base.finalizer"><code>Base.finalizer</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">finalizer(f, x)</code></pre><p>Register a function <code>f(x)</code> to be called when there are no program-accessible references to <code>x</code>, and return <code>x</code>. The type of <code>x</code> must be a <code>mutable struct</code>, otherwise the behavior of this function is unpredictable.</p><p><code>f</code> must not cause a task switch, which excludes most I/O operations such as <code>println</code>. Using the <code>@async</code> macro (to defer context switching to outside of the finalizer) or <code>ccall</code> to directly invoke IO functions in C may be helpful for debugging purposes.</p><p><strong>Examples</strong></p><pre><code class="language-julia">finalizer(my_mutable_struct) do x
@async println("Finalizing $x.")
end
finalizer(my_mutable_struct) do x
ccall(:jl_safe_printf, Cvoid, (Cstring, Cstring), "Finalizing %s.", repr(x))
end</code></pre><p>A finalizer may be registered at object construction. In the following example note that we implicitly rely on the finalizer returning the newly created mutable struct <code>x</code>.</p><p><strong>Example</strong></p><pre><code class="language-julia">mutable struct MyMutableStruct
bar
function MyMutableStruct(bar)
x = new(bar)
f(t) = @async println("Finalizing $t.")
finalizer(f, x)
end
end</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/gcutils.jl#L7-L43">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.finalize" href="#Base.finalize"><code>Base.finalize</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">finalize(x)</code></pre><p>Immediately run finalizers registered for object <code>x</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/gcutils.jl#L62-L66">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.copy" href="#Base.copy"><code>Base.copy</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">copy(x)</code></pre><p>Create a shallow copy of <code>x</code>: the outer structure is copied, but not all internal values. For example, copying an array produces a new array with identically-same elements as the original.</p><p>See also <a href="../arrays/#Base.copy!"><code>copy!</code></a>, <a href="../c/#Base.copyto!"><code>copyto!</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/array.jl#L358-L366">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.deepcopy" href="#Base.deepcopy"><code>Base.deepcopy</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">deepcopy(x)</code></pre><p>Create a deep copy of <code>x</code>: everything is copied recursively, resulting in a fully independent object. For example, deep-copying an array produces a new array whose elements are deep copies of the original elements. Calling <code>deepcopy</code> on an object should generally have the same effect as serializing and then deserializing it.</p><p>While it isn't normally necessary, user-defined types can override the default <code>deepcopy</code> behavior by defining a specialized version of the function <code>deepcopy_internal(x::T, dict::IdDict)</code> (which shouldn't otherwise be used), where <code>T</code> is the type to be specialized for, and <code>dict</code> keeps track of objects copied so far within the recursion. Within the definition, <code>deepcopy_internal</code> should be used in place of <code>deepcopy</code>, and the <code>dict</code> variable should be updated as appropriate before returning.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/deepcopy.jl#L8-L23">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.getproperty" href="#Base.getproperty"><code>Base.getproperty</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">getproperty(value, name::Symbol)
getproperty(value, name::Symbol, order::Symbol)</code></pre><p>The syntax <code>a.b</code> calls <code>getproperty(a, :b)</code>. The syntax <code>@atomic order a.b</code> calls <code>getproperty(a, :b, :order)</code> and the syntax <code>@atomic a.b</code> calls <code>getproperty(a, :b, :sequentially_consistent)</code>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> struct MyType
x
end
julia> function Base.getproperty(obj::MyType, sym::Symbol)
if sym === :special
return obj.x + 1
else # fallback to getfield
return getfield(obj, sym)
end
end
julia> obj = MyType(1);
julia> obj.special
2
julia> obj.x
1</code></pre><p>See also <a href="#Core.getfield"><code>getfield</code></a>, <a href="#Base.propertynames"><code>propertynames</code></a> and <a href="#Base.setproperty!"><code>setproperty!</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L2689-L2723">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.setproperty!" href="#Base.setproperty!"><code>Base.setproperty!</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">setproperty!(value, name::Symbol, x)
setproperty!(value, name::Symbol, x, order::Symbol)</code></pre><p>The syntax <code>a.b = c</code> calls <code>setproperty!(a, :b, c)</code>. The syntax <code>@atomic order a.b = c</code> calls <code>setproperty!(a, :b, c, :order)</code> and the syntax <code>@atomic a.b = c</code> calls <code>getproperty(a, :b, :sequentially_consistent)</code>.</p><p>See also <a href="#Core.setfield!"><code>setfield!</code></a>, <a href="#Base.propertynames"><code>propertynames</code></a> and <a href="#Base.getproperty"><code>getproperty</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L2726-L2737">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.propertynames" href="#Base.propertynames"><code>Base.propertynames</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">propertynames(x, private=false)</code></pre><p>Get a tuple or a vector of the properties (<code>x.property</code>) of an object <code>x</code>. This is typically the same as <a href="#Base.fieldnames"><code>fieldnames(typeof(x))</code></a>, but types that overload <a href="#Base.getproperty"><code>getproperty</code></a> should generally overload <code>propertynames</code> as well to get the properties of an instance of the type.</p><p><code>propertynames(x)</code> may return only "public" property names that are part of the documented interface of <code>x</code>. If you want it to also return "private" fieldnames intended for internal use, pass <code>true</code> for the optional second argument. REPL tab completion on <code>x.</code> shows only the <code>private=false</code> properties.</p><p>See also: <a href="#Base.hasproperty"><code>hasproperty</code></a>, <a href="#Base.hasfield"><code>hasfield</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L1736-L1750">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.hasproperty" href="#Base.hasproperty"><code>Base.hasproperty</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">hasproperty(x, s::Symbol)</code></pre><p>Return a boolean indicating whether the object <code>x</code> has <code>s</code> as one of its own properties.</p><div class="admonition is-compat"><header class="admonition-header">Julia 1.2</header><div class="admonition-body"><p>This function requires at least Julia 1.2.</p></div></div><p>See also: <a href="#Base.propertynames"><code>propertynames</code></a>, <a href="#Base.hasfield"><code>hasfield</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L1755-L1764">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.getfield" href="#Core.getfield"><code>Core.getfield</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">getfield(value, name::Symbol, [order::Symbol])
getfield(value, i::Int, [order::Symbol])</code></pre><p>Extract a field from a composite <code>value</code> by name or position. Optionally, an ordering can be defined for the operation. If the field was declared <code>@atomic</code>, the specification is strongly recommended to be compatible with the stores to that location. Otherwise, if not declared as <code>@atomic</code>, this parameter must be <code>:not_atomic</code> if specified. See also <a href="#Base.getproperty"><code>getproperty</code></a> and <a href="#Base.fieldnames"><code>fieldnames</code></a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> a = 1//2
1//2
julia> getfield(a, :num)
1
julia> a.num
1
julia> getfield(a, 1)
1</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L1943-L1968">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.setfield!" href="#Core.setfield!"><code>Core.setfield!</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">setfield!(value, name::Symbol, x, [order::Symbol])
setfield!(value, i::Int, x, [order::Symbol])</code></pre><p>Assign <code>x</code> to a named field in <code>value</code> of composite type. The <code>value</code> must be mutable and <code>x</code> must be a subtype of <code>fieldtype(typeof(value), name)</code>. Additionally, an ordering can be specified for this operation. If the field was declared <code>@atomic</code>, this specification is mandatory. Otherwise, if not declared as <code>@atomic</code>, it must be <code>:not_atomic</code> if specified. See also <a href="#Base.setproperty!"><code>setproperty!</code></a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> mutable struct MyMutableStruct
field::Int
end
julia> a = MyMutableStruct(1);
julia> setfield!(a, :field, 2);
julia> getfield(a, :field)
2
julia> a = 1//2
1//2
julia> setfield!(a, :num, 3);
ERROR: setfield!: immutable struct of type Rational cannot be changed</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L1971-L2001">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.isdefined" href="#Core.isdefined"><code>Core.isdefined</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">isdefined(m::Module, s::Symbol, [order::Symbol])
isdefined(object, s::Symbol, [order::Symbol])
isdefined(object, index::Int, [order::Symbol])</code></pre><p>Tests whether a global variable or object field is defined. The arguments can be a module and a symbol or a composite object and field name (as a symbol) or index. Optionally, an ordering can be defined for the operation. If the field was declared <code>@atomic</code>, the specification is strongly recommended to be compatible with the stores to that location. Otherwise, if not declared as <code>@atomic</code>, this parameter must be <code>:not_atomic</code> if specified.</p><p>To test whether an array element is defined, use <a href="../arrays/#Base.isassigned"><code>isassigned</code></a> instead.</p><p>See also <a href="#Base.@isdefined"><code>@isdefined</code></a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> isdefined(Base, :sum)
true
julia> isdefined(Base, :NonExistentMethod)
false
julia> a = 1//2;
julia> isdefined(a, 2)
true
julia> isdefined(a, 3)
false
julia> isdefined(a, :num)
true
julia> isdefined(a, :numerator)
false</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L2076-L2114">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.@isdefined" href="#Base.@isdefined"><code>Base.@isdefined</code></a> — <span class="docstring-category">Macro</span></header><section><div><pre><code class="language-julia">@isdefined s -> Bool</code></pre><p>Tests whether variable <code>s</code> is defined in the current scope.</p><p>See also <a href="#Core.isdefined"><code>isdefined</code></a> for field properties and <a href="../arrays/#Base.isassigned"><code>isassigned</code></a> for array indexes or <a href="../collections/#Base.haskey"><code>haskey</code></a> for other mappings.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> @isdefined newvar
false
julia> newvar = 1
1
julia> @isdefined newvar
true
julia> function f()
println(@isdefined x)
x = 3
println(@isdefined x)
end
f (generic function with 1 method)
julia> f()
false
true</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/essentials.jl#L119-L149">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.convert" href="#Base.convert"><code>Base.convert</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">convert(T, x)</code></pre><p>Convert <code>x</code> to a value of type <code>T</code>.</p><p>If <code>T</code> is an <a href="../numbers/#Core.Integer"><code>Integer</code></a> type, an <a href="#Core.InexactError"><code>InexactError</code></a> will be raised if <code>x</code> is not representable by <code>T</code>, for example if <code>x</code> is not integer-valued, or is outside the range supported by <code>T</code>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> convert(Int, 3.0)
3
julia> convert(Int, 3.5)
ERROR: InexactError: Int64(3.5)
Stacktrace:
[...]</code></pre><p>If <code>T</code> is a <a href="../numbers/#Core.AbstractFloat"><code>AbstractFloat</code></a> type, then it will return the closest value to <code>x</code> representable by <code>T</code>.</p><pre><code class="language-julia-repl">julia> x = 1/3
0.3333333333333333
julia> convert(Float32, x)
0.33333334f0
julia> convert(BigFloat, x)
0.333333333333333314829616256247390992939472198486328125</code></pre><p>If <code>T</code> is a collection type and <code>x</code> a collection, the result of <code>convert(T, x)</code> may alias all or part of <code>x</code>.</p><pre><code class="language-julia-repl">julia> x = Int[1, 2, 3];
julia> y = convert(Vector{Int}, x);
julia> y === x
true</code></pre><p>See also: <a href="../math/#Base.round-Tuple{Type, Any}"><code>round</code></a>, <a href="../math/#Base.trunc"><code>trunc</code></a>, <a href="#Base.oftype"><code>oftype</code></a>, <a href="../arrays/#Base.reinterpret"><code>reinterpret</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/essentials.jl#L164-L210">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.promote" href="#Base.promote"><code>Base.promote</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">promote(xs...)</code></pre><p>Convert all arguments to a common type, and return them all (as a tuple). If no arguments can be converted, an error is raised.</p><p>See also: [<code>promote_type</code>], [<code>promote_rule</code>].</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> promote(Int8(1), Float16(4.5), Float32(4.1))
(1.0f0, 4.5f0, 4.1f0)</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/promotion.jl#L317-L330">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.oftype" href="#Base.oftype"><code>Base.oftype</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">oftype(x, y)</code></pre><p>Convert <code>y</code> to the type of <code>x</code> (<code>convert(typeof(x), y)</code>).</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> x = 4;
julia> y = 3.;
julia> oftype(x, y)
3
julia> oftype(y, x)
4.0</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/essentials.jl#L373-L390">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.widen" href="#Base.widen"><code>Base.widen</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">widen(x)</code></pre><p>If <code>x</code> is a type, return a "larger" type, defined so that arithmetic operations <code>+</code> and <code>-</code> are guaranteed not to overflow nor lose precision for any combination of values that type <code>x</code> can hold.</p><p>For fixed-size integer types less than 128 bits, <code>widen</code> will return a type with twice the number of bits.</p><p>If <code>x</code> is a value, it is converted to <code>widen(typeof(x))</code>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> widen(Int32)
Int64
julia> widen(1.5f0)
1.5</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/operators.jl#L874-L894">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.identity" href="#Base.identity"><code>Base.identity</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">identity(x)</code></pre><p>The identity function. Returns its argument.</p><p>See also: <a href="../numbers/#Base.one"><code>one</code></a>, <a href="../numbers/#Base.oneunit"><code>oneunit</code></a>, and <a href="../../stdlib/LinearAlgebra/#man-linalg"><code>LinearAlgebra</code></a>'s <code>I</code>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> identity("Well, what did you expect?")
"Well, what did you expect?"</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/operators.jl#L513-L525">source</a></section></article><h2 id="Properties-of-Types"><a class="docs-heading-anchor" href="#Properties-of-Types">Properties of Types</a><a id="Properties-of-Types-1"></a><a class="docs-heading-anchor-permalink" href="#Properties-of-Types" title="Permalink"></a></h2><h3 id="Type-relations"><a class="docs-heading-anchor" href="#Type-relations">Type relations</a><a id="Type-relations-1"></a><a class="docs-heading-anchor-permalink" href="#Type-relations" title="Permalink"></a></h3><article class="docstring"><header><a class="docstring-binding" id="Base.supertype" href="#Base.supertype"><code>Base.supertype</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">supertype(T::DataType)</code></pre><p>Return the supertype of DataType <code>T</code>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> supertype(Int32)
Signed</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/operators.jl#L32-L42">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.Type" href="#Core.Type"><code>Core.Type</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Core.Type{T}</code></pre><p><code>Core.Type</code> is an abstract type which has all type objects as its instances. The only instance of the singleton type <code>Core.Type{T}</code> is the object <code>T</code>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> isa(Type{Float64}, Type)
true
julia> isa(Float64, Type)
true
julia> isa(Real, Type{Float64})
false
julia> isa(Real, Type{Real})
true</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L1306-L1327">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.DataType" href="#Core.DataType"><code>Core.DataType</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">DataType <: Type{T}</code></pre><p><code>DataType</code> represents explicitly declared types that have names, explicitly declared supertypes, and, optionally, parameters. Every concrete value in the system is an instance of some <code>DataType</code>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> typeof(Real)
DataType
julia> typeof(Int)
DataType
julia> struct Point
x::Int
y
end
julia> typeof(Point)
DataType</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L1330-L1353">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.:<:" href="#Core.:<:"><code>Core.:<:</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia"><:(T1, T2)</code></pre><p>Subtype operator: returns <code>true</code> if and only if all values of type <code>T1</code> are also of type <code>T2</code>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> Float64 <: AbstractFloat
true
julia> Vector{Int} <: AbstractArray
true
julia> Matrix{Float64} <: Matrix{AbstractFloat}
false</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/operators.jl#L5-L22">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.:>:" href="#Base.:>:"><code>Base.:>:</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">>:(T1, T2)</code></pre><p>Supertype operator, equivalent to <code>T2 <: T1</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/operators.jl#L25-L29">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.typejoin" href="#Base.typejoin"><code>Base.typejoin</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">typejoin(T, S)</code></pre><p>Return the closest common ancestor of <code>T</code> and <code>S</code>, i.e. the narrowest type from which they both inherit.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/promotion.jl#L5-L10">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.typeintersect" href="#Base.typeintersect"><code>Base.typeintersect</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">typeintersect(T::Type, S::Type)</code></pre><p>Compute a type that contains the intersection of <code>T</code> and <code>S</code>. Usually this will be the smallest such type or one close to it.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L677-L682">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.promote_type" href="#Base.promote_type"><code>Base.promote_type</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">promote_type(type1, type2)</code></pre><p>Promotion refers to converting values of mixed types to a single common type. <code>promote_type</code> represents the default promotion behavior in Julia when operators (usually mathematical) are given arguments of differing types. <code>promote_type</code> generally tries to return a type which can at least approximate most values of either input type without excessively widening. Some loss is tolerated; for example, <code>promote_type(Int64, Float64)</code> returns <a href="../numbers/#Core.Float64"><code>Float64</code></a> even though strictly, not all <a href="../numbers/#Core.Int64"><code>Int64</code></a> values can be represented exactly as <code>Float64</code> values.</p><p>See also: <a href="#Base.promote"><code>promote</code></a>, <a href="#Base.promote_typejoin"><code>promote_typejoin</code></a>, <a href="#Base.promote_rule"><code>promote_rule</code></a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> promote_type(Int64, Float64)
Float64
julia> promote_type(Int32, Int64)
Int64
julia> promote_type(Float32, BigInt)
BigFloat
julia> promote_type(Int16, Float16)
Float16
julia> promote_type(Int64, Float16)
Float16
julia> promote_type(Int8, UInt16)
UInt16</code></pre><div class="admonition is-warning"><header class="admonition-header">Don't overload this directly</header><div class="admonition-body"><p>To overload promotion for your own types you should overload <a href="#Base.promote_rule"><code>promote_rule</code></a>. <code>promote_type</code> calls <code>promote_rule</code> internally to determine the type. Overloading <code>promote_type</code> directly can cause ambiguity errors.</p></div></div></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/promotion.jl#L240-L279">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.promote_rule" href="#Base.promote_rule"><code>Base.promote_rule</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">promote_rule(type1, type2)</code></pre><p>Specifies what type should be used by <a href="#Base.promote"><code>promote</code></a> when given values of types <code>type1</code> and <code>type2</code>. This function should not be called directly, but should have definitions added to it for new types as appropriate.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/promotion.jl#L301-L307">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.promote_typejoin" href="#Base.promote_typejoin"><code>Base.promote_typejoin</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">promote_typejoin(T, S)</code></pre><p>Compute a type that contains both <code>T</code> and <code>S</code>, which could be either a parent of both types, or a <code>Union</code> if appropriate. Falls back to <a href="#Base.typejoin"><code>typejoin</code></a>.</p><p>See instead <a href="#Base.promote"><code>promote</code></a>, <a href="#Base.promote_type"><code>promote_type</code></a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> Base.promote_typejoin(Int, Float64)
Real
julia> Base.promote_type(Int, Float64)
Float64</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/promotion.jl#L143-L160">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.isdispatchtuple" href="#Base.isdispatchtuple"><code>Base.isdispatchtuple</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">isdispatchtuple(T)</code></pre><p>Determine whether type <code>T</code> is a tuple "leaf type", meaning it could appear as a type signature in dispatch and has no subtypes (or supertypes) which could appear in a call.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L595-L601">source</a></section></article><h3 id="Declared-structure"><a class="docs-heading-anchor" href="#Declared-structure">Declared structure</a><a id="Declared-structure-1"></a><a class="docs-heading-anchor-permalink" href="#Declared-structure" title="Permalink"></a></h3><article class="docstring"><header><a class="docstring-binding" id="Base.ismutable" href="#Base.ismutable"><code>Base.ismutable</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">ismutable(v) -> Bool</code></pre><p>Return <code>true</code> if and only if value <code>v</code> is mutable. See <a href="base/@ref">Mutable Composite Types</a> for a discussion of immutability. Note that this function works on values, so if you give it a type, it will tell you that a value of <code>DataType</code> is mutable.</p><p>See also <a href="#Base.isbits"><code>isbits</code></a>, <a href="#Base.isstructtype"><code>isstructtype</code></a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> ismutable(1)
false
julia> ismutable([1,2])
true</code></pre><div class="admonition is-compat"><header class="admonition-header">Julia 1.5</header><div class="admonition-body"><p>This function requires at least Julia 1.5.</p></div></div></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L493-L513">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.isimmutable" href="#Base.isimmutable"><code>Base.isimmutable</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">isimmutable(v) -> Bool</code></pre><div class="admonition is-warning"><header class="admonition-header">Warning</header><div class="admonition-body"><p>Consider using <code>!ismutable(v)</code> instead, as <code>isimmutable(v)</code> will be replaced by <code>!ismutable(v)</code> in a future release. (Since Julia 1.5)</p></div></div><p>Return <code>true</code> iff value <code>v</code> is immutable. See <a href="base/@ref">Mutable Composite Types</a> for a discussion of immutability. Note that this function works on values, so if you give it a type, it will tell you that a value of <code>DataType</code> is mutable.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> isimmutable(1)
true
julia> isimmutable([1,2])
false</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/deprecated.jl#L188-L204">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.isabstracttype" href="#Base.isabstracttype"><code>Base.isabstracttype</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">isabstracttype(T)</code></pre><p>Determine whether type <code>T</code> was declared as an abstract type (i.e. using the <code>abstract</code> keyword).</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> isabstracttype(AbstractArray)
true
julia> isabstracttype(Vector)
false</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L647-L661">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.isprimitivetype" href="#Base.isprimitivetype"><code>Base.isprimitivetype</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">isprimitivetype(T) -> Bool</code></pre><p>Determine whether type <code>T</code> was declared as a primitive type (i.e. using the <code>primitive</code> keyword).</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L548-L553">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.issingletontype" href="#Base.issingletontype"><code>Base.issingletontype</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">Base.issingletontype(T)</code></pre><p>Determine whether type <code>T</code> has exactly one possible instance; for example, a struct type with no fields.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L669-L674">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.isstructtype" href="#Base.isstructtype"><code>Base.isstructtype</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">isstructtype(T) -> Bool</code></pre><p>Determine whether type <code>T</code> was declared as a struct type (i.e. using the <code>struct</code> or <code>mutable struct</code> keyword).</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L533-L538">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.nameof-Tuple{DataType}" href="#Base.nameof-Tuple{DataType}"><code>Base.nameof</code></a> — <span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia">nameof(t::DataType) -> Symbol</code></pre><p>Get the name of a (potentially <code>UnionAll</code>-wrapped) <code>DataType</code> (without its parent module) as a symbol.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> module Foo
struct S{T}
end
end
Foo
julia> nameof(Foo.S{T} where T)
:S</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L220-L237">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.fieldnames" href="#Base.fieldnames"><code>Base.fieldnames</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">fieldnames(x::DataType)</code></pre><p>Get a tuple with the names of the fields of a <code>DataType</code>.</p><p>See also <a href="#Base.propertynames"><code>propertynames</code></a>, <a href="#Base.hasfield"><code>hasfield</code></a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> fieldnames(Rational)
(:num, :den)
julia> fieldnames(typeof(1+im))
(:re, :im)</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L169-L184">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.fieldname" href="#Base.fieldname"><code>Base.fieldname</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">fieldname(x::DataType, i::Integer)</code></pre><p>Get the name of field <code>i</code> of a <code>DataType</code>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> fieldname(Rational, 1)
:num
julia> fieldname(Rational, 2)
:den</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L135-L148">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.hasfield" href="#Base.hasfield"><code>Base.hasfield</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">hasfield(T::Type, name::Symbol)</code></pre><p>Return a boolean indicating whether <code>T</code> has <code>name</code> as one of its own fields.</p><p>See also <a href="#Base.fieldnames"><code>fieldnames</code></a>, <a href="#Base.fieldcount"><code>fieldcount</code></a>, <a href="#Base.hasproperty"><code>hasproperty</code></a>.</p><div class="admonition is-compat"><header class="admonition-header">Julia 1.2</header><div class="admonition-body"><p>This function requires at least Julia 1.2.</p></div></div><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> struct Foo
bar::Int
end
julia> hasfield(Foo, :bar)
true
julia> hasfield(Foo, :x)
false</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L192-L214">source</a></section></article><h3 id="Memory-layout"><a class="docs-heading-anchor" href="#Memory-layout">Memory layout</a><a id="Memory-layout-1"></a><a class="docs-heading-anchor-permalink" href="#Memory-layout" title="Permalink"></a></h3><article class="docstring"><header><a class="docstring-binding" id="Base.sizeof-Tuple{Type}" href="#Base.sizeof-Tuple{Type}"><code>Base.sizeof</code></a> — <span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia">sizeof(T::DataType)
sizeof(obj)</code></pre><p>Size, in bytes, of the canonical binary representation of the given <code>DataType</code> <code>T</code>, if any. Or the size, in bytes, of object <code>obj</code> if it is not a <code>DataType</code>.</p><p>See also <a href="#Base.summarysize"><code>summarysize</code></a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> sizeof(Float32)
4
julia> sizeof(ComplexF64)
16
julia> sizeof(1.0)
8
julia> sizeof(collect(1.0:10.0))
80</code></pre><p>If <code>DataType</code> <code>T</code> does not have a specific size, an error is thrown.</p><pre><code class="language-julia-repl">julia> sizeof(AbstractArray)
ERROR: Abstract type AbstractArray does not have a definite size.
Stacktrace:
[...]</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/essentials.jl#L440-L472">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.isconcretetype" href="#Base.isconcretetype"><code>Base.isconcretetype</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">isconcretetype(T)</code></pre><p>Determine whether type <code>T</code> is a concrete type, meaning it could have direct instances (values <code>x</code> such that <code>typeof(x) === T</code>).</p><p>See also: <a href="#Base.isbits"><code>isbits</code></a>, <a href="#Base.isabstracttype"><code>isabstracttype</code></a>, <a href="#Base.issingletontype"><code>issingletontype</code></a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> isconcretetype(Complex)
false
julia> isconcretetype(Complex{Float32})
true
julia> isconcretetype(Vector{Complex})
true
julia> isconcretetype(Vector{Complex{Float32}})
true
julia> isconcretetype(Union{})
false
julia> isconcretetype(Union{Int,String})
false</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L616-L644">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.isbits" href="#Base.isbits"><code>Base.isbits</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">isbits(x)</code></pre><p>Return <code>true</code> if <code>x</code> is an instance of an <a href="#Base.isbitstype"><code>isbitstype</code></a> type.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L588-L592">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.isbitstype" href="#Base.isbitstype"><code>Base.isbitstype</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">isbitstype(T)</code></pre><p>Return <code>true</code> if type <code>T</code> is a "plain data" type, meaning it is immutable and contains no references to other values, only <code>primitive</code> types and other <code>isbitstype</code> types. Typical examples are numeric types such as <a href="../numbers/#Core.UInt8"><code>UInt8</code></a>, <a href="../numbers/#Core.Float64"><code>Float64</code></a>, and <a href="../numbers/#Base.Complex"><code>Complex{Float64}</code></a>. This category of types is significant since they are valid as type parameters, may not track <a href="#Core.isdefined"><code>isdefined</code></a> / <a href="../arrays/#Base.isassigned"><code>isassigned</code></a> status, and have a defined layout that is compatible with C.</p><p>See also <a href="#Base.isbits"><code>isbits</code></a>, <a href="#Base.isprimitivetype"><code>isprimitivetype</code></a>, <a href="#Base.ismutable"><code>ismutable</code></a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> isbitstype(Complex{Float64})
true
julia> isbitstype(Complex)
false</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L563-L585">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.fieldtype" href="#Core.fieldtype"><code>Core.fieldtype</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">fieldtype(T, name::Symbol | index::Int)</code></pre><p>Determine the declared type of a field (specified by name or index) in a composite DataType <code>T</code>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> struct Foo
x::Int64
y::String
end
julia> fieldtype(Foo, :x)
Int64
julia> fieldtype(Foo, 2)
String</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L715-L733">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.fieldtypes" href="#Base.fieldtypes"><code>Base.fieldtypes</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">fieldtypes(T::Type)</code></pre><p>The declared types of all fields in a composite DataType <code>T</code> as a tuple.</p><div class="admonition is-compat"><header class="admonition-header">Julia 1.1</header><div class="admonition-body"><p>This function requires at least Julia 1.1.</p></div></div><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> struct Foo
x::Int64
y::String
end
julia> fieldtypes(Foo)
(Int64, String)</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L812-L830">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.fieldcount" href="#Base.fieldcount"><code>Base.fieldcount</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">fieldcount(t::Type)</code></pre><p>Get the number of fields that an instance of the given type would have. An error is thrown if the type is too abstract to determine this.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L772-L777">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.fieldoffset" href="#Base.fieldoffset"><code>Base.fieldoffset</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">fieldoffset(type, i)</code></pre><p>The byte offset of field <code>i</code> of a type relative to the data start. For example, we could use it in the following manner to summarize information about a struct:</p><pre><code class="language-julia-repl">julia> structinfo(T) = [(fieldoffset(T,i), fieldname(T,i), fieldtype(T,i)) for i = 1:fieldcount(T)];
julia> structinfo(Base.Filesystem.StatStruct)
13-element Vector{Tuple{UInt64, Symbol, Type}}:
(0x0000000000000000, :desc, Union{RawFD, String})
(0x0000000000000008, :device, UInt64)
(0x0000000000000010, :inode, UInt64)
(0x0000000000000018, :mode, UInt64)
(0x0000000000000020, :nlink, Int64)
(0x0000000000000028, :uid, UInt64)
(0x0000000000000030, :gid, UInt64)
(0x0000000000000038, :rdev, UInt64)
(0x0000000000000040, :size, Int64)
(0x0000000000000048, :blksize, Int64)
(0x0000000000000050, :blocks, Int64)
(0x0000000000000058, :mtime, Float64)
(0x0000000000000060, :ctime, Float64)</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L687-L712">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.datatype_alignment" href="#Base.datatype_alignment"><code>Base.datatype_alignment</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">Base.datatype_alignment(dt::DataType) -> Int</code></pre><p>Memory allocation minimum alignment for instances of this type. Can be called on any <code>isconcretetype</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L356-L361">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.datatype_haspadding" href="#Base.datatype_haspadding"><code>Base.datatype_haspadding</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">Base.datatype_haspadding(dt::DataType) -> Bool</code></pre><p>Return whether the fields of instances of this type are packed in memory, with no intervening padding bytes. Can be called on any <code>isconcretetype</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L395-L401">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.datatype_pointerfree" href="#Base.datatype_pointerfree"><code>Base.datatype_pointerfree</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">Base.datatype_pointerfree(dt::DataType) -> Bool</code></pre><p>Return whether instances of this type can contain references to gc-managed memory. Can be called on any <code>isconcretetype</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L421-L426">source</a></section></article><h3 id="Special-values"><a class="docs-heading-anchor" href="#Special-values">Special values</a><a id="Special-values-1"></a><a class="docs-heading-anchor-permalink" href="#Special-values" title="Permalink"></a></h3><article class="docstring"><header><a class="docstring-binding" id="Base.typemin" href="#Base.typemin"><code>Base.typemin</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">typemin(T)</code></pre><p>The lowest value representable by the given (real) numeric DataType <code>T</code>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> typemin(Float16)
-Inf16
julia> typemin(Float32)
-Inf32</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/int.jl#L742-L755">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.typemax" href="#Base.typemax"><code>Base.typemax</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">typemax(T)</code></pre><p>The highest value representable by the given (real) numeric <code>DataType</code>.</p><p>See also: <a href="#Base.floatmax"><code>floatmax</code></a>, <a href="#Base.typemin"><code>typemin</code></a>, <a href="#Base.eps-Tuple{Type{<:AbstractFloat}}"><code>eps</code></a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> typemax(Int8)
127
julia> typemax(UInt32)
0xffffffff
julia> typemax(Float64)
Inf
julia> floatmax(Float32) # largest finite floating point number
3.4028235f38</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/int.jl#L758-L779">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.floatmin" href="#Base.floatmin"><code>Base.floatmin</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">floatmin(T = Float64)</code></pre><p>Return the smallest positive normal number representable by the floating-point type <code>T</code>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> floatmin(Float16)
Float16(6.104e-5)
julia> floatmin(Float32)
1.1754944f-38
julia> floatmin()
2.2250738585072014e-308</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/float.jl#L834-L851">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.floatmax" href="#Base.floatmax"><code>Base.floatmax</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">floatmax(T = Float64)</code></pre><p>Return the largest finite number representable by the floating-point type <code>T</code>.</p><p>See also: <a href="#Base.typemax"><code>typemax</code></a>, <a href="#Base.floatmin"><code>floatmin</code></a>, <a href="#Base.eps-Tuple{Type{<:AbstractFloat}}"><code>eps</code></a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> floatmax(Float16)
Float16(6.55e4)
julia> floatmax(Float32)
3.4028235f38
julia> floatmax()
1.7976931348623157e308
julia> typemax(Float64)
Inf</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/float.jl#L854-L875">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.maxintfloat" href="#Base.maxintfloat"><code>Base.maxintfloat</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">maxintfloat(T=Float64)</code></pre><p>The largest consecutive integer-valued floating-point number that is exactly represented in the given floating-point type <code>T</code> (which defaults to <code>Float64</code>).</p><p>That is, <code>maxintfloat</code> returns the smallest positive integer-valued floating-point number <code>n</code> such that <code>n+1</code> is <em>not</em> exactly representable in the type <code>T</code>.</p><p>When an <code>Integer</code>-type value is needed, use <code>Integer(maxintfloat(T))</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/floatfuncs.jl#L19-L29">source</a></section><section><div><pre><code class="language-none">maxintfloat(T, S)</code></pre><p>The largest consecutive integer representable in the given floating-point type <code>T</code> that also does not exceed the maximum integer representable by the integer type <code>S</code>. Equivalently, it is the minimum of <code>maxintfloat(T)</code> and <a href="#Base.typemax"><code>typemax(S)</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/floatfuncs.jl#L35-L41">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.eps-Tuple{Type{<:AbstractFloat}}" href="#Base.eps-Tuple{Type{<:AbstractFloat}}"><code>Base.eps</code></a> — <span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia">eps(::Type{T}) where T<:AbstractFloat
eps()</code></pre><p>Return the <em>machine epsilon</em> of the floating point type <code>T</code> (<code>T = Float64</code> by default). This is defined as the gap between 1 and the next largest value representable by <code>typeof(one(T))</code>, and is equivalent to <code>eps(one(T))</code>. (Since <code>eps(T)</code> is a bound on the <em>relative error</em> of <code>T</code>, it is a "dimensionless" quantity like <a href="../numbers/#Base.one"><code>one</code></a>.)</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> eps()
2.220446049250313e-16
julia> eps(Float32)
1.1920929f-7
julia> 1.0 + eps()
1.0000000000000002
julia> 1.0 + eps()/2
1.0</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/float.jl#L881-L904">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.eps-Tuple{AbstractFloat}" href="#Base.eps-Tuple{AbstractFloat}"><code>Base.eps</code></a> — <span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia">eps(x::AbstractFloat)</code></pre><p>Return the <em>unit in last place</em> (ulp) of <code>x</code>. This is the distance between consecutive representable floating point values at <code>x</code>. In most cases, if the distance on either side of <code>x</code> is different, then the larger of the two is taken, that is</p><pre><code class="language-none">eps(x) == max(x-prevfloat(x), nextfloat(x)-x)</code></pre><p>The exceptions to this rule are the smallest and largest finite values (e.g. <code>nextfloat(-Inf)</code> and <code>prevfloat(Inf)</code> for <a href="../numbers/#Core.Float64"><code>Float64</code></a>), which round to the smaller of the values.</p><p>The rationale for this behavior is that <code>eps</code> bounds the floating point rounding error. Under the default <code>RoundNearest</code> rounding mode, if <span>$y$</span> is a real number and <span>$x$</span> is the nearest floating point number to <span>$y$</span>, then</p><p class="math-container">\[|y-x| \leq \operatorname{eps}(x)/2.\]</p><p>See also: <a href="../numbers/#Base.nextfloat"><code>nextfloat</code></a>, <a href="../numbers/#Base.issubnormal"><code>issubnormal</code></a>, <a href="#Base.floatmax"><code>floatmax</code></a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> eps(1.0)
2.220446049250313e-16
julia> eps(prevfloat(2.0))
2.220446049250313e-16
julia> eps(2.0)
4.440892098500626e-16
julia> x = prevfloat(Inf) # largest finite Float64
1.7976931348623157e308
julia> x + eps(x)/2 # rounds up
Inf
julia> x + prevfloat(eps(x)/2) # rounds down
1.7976931348623157e308</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/float.jl#L907-L950">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.instances" href="#Base.instances"><code>Base.instances</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">instances(T::Type)</code></pre><p>Return a collection of all instances of the given type, if applicable. Mostly used for enumerated types (see <code>@enum</code>).</p><p><strong>Example</strong></p><pre><code class="language-julia-repl">julia> @enum Color red blue green
julia> instances(Color)
(red, blue, green)</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L835-L848">source</a></section></article><h2 id="Special-Types"><a class="docs-heading-anchor" href="#Special-Types">Special Types</a><a id="Special-Types-1"></a><a class="docs-heading-anchor-permalink" href="#Special-Types" title="Permalink"></a></h2><article class="docstring"><header><a class="docstring-binding" id="Core.Any" href="#Core.Any"><code>Core.Any</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Any::DataType</code></pre><p><code>Any</code> is the union of all types. It has the defining property <code>isa(x, Any) == true</code> for any <code>x</code>. <code>Any</code> therefore describes the entire universe of possible values. For example <code>Integer</code> is a subset of <code>Any</code> that includes <code>Int</code>, <code>Int8</code>, and other integer types.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L2491-L2497">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.Union" href="#Core.Union"><code>Core.Union</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Union{Types...}</code></pre><p>A type union is an abstract type which includes all instances of any of its argument types. The empty union <a href="#Union{}"><code>Union{}</code></a> is the bottom type of Julia.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> IntOrString = Union{Int,AbstractString}
Union{Int64, AbstractString}
julia> 1 :: IntOrString
1
julia> "Hello!" :: IntOrString
"Hello!"
julia> 1.0 :: IntOrString
ERROR: TypeError: in typeassert, expected Union{Int64, AbstractString}, got a value of type Float64</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L2515-L2535">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Union{}" href="#Union{}"><code>Union{}</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">Union{}</code></pre><p><code>Union{}</code>, the empty <a href="#Core.Union"><code>Union</code></a> of types, is the type that has no values. That is, it has the defining property <code>isa(x, Union{}) == false</code> for any <code>x</code>. <code>Base.Bottom</code> is defined as its alias and the type of <code>Union{}</code> is <code>Core.TypeofBottom</code>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> isa(nothing, Union{})
false</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L2500-L2512">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.UnionAll" href="#Core.UnionAll"><code>Core.UnionAll</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">UnionAll</code></pre><p>A union of types over all values of a type parameter. <code>UnionAll</code> is used to describe parametric types where the values of some parameters are not known.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> typeof(Vector)
UnionAll
julia> typeof(Vector{Int})
DataType</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L2539-L2553">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.Tuple" href="#Core.Tuple"><code>Core.Tuple</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Tuple{Types...}</code></pre><p>Tuples are an abstraction of the arguments of a function – without the function itself. The salient aspects of a function's arguments are their order and their types. Therefore a tuple type is similar to a parameterized immutable type where each parameter is the type of one field. Tuple types may have any number of parameters.</p><p>Tuple types are covariant in their parameters: <code>Tuple{Int}</code> is a subtype of <code>Tuple{Any}</code>. Therefore <code>Tuple{Any}</code> is considered an abstract type, and tuple types are only concrete if their parameters are. Tuples do not have field names; fields are only accessed by index.</p><p>See the manual section on <a href="base/@ref">Tuple Types</a>.</p><p>See also <a href="#Core.Vararg"><code>Vararg</code></a>, <a href="#Core.NTuple"><code>NTuple</code></a>, <a href="#Core.tuple"><code>tuple</code></a>, <a href="#Core.NamedTuple"><code>NamedTuple</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L2622-L2636">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.NTuple" href="#Core.NTuple"><code>Core.NTuple</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">NTuple{N, T}</code></pre><p>A compact way of representing the type for a tuple of length <code>N</code> where all elements are of type <code>T</code>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> isa((1, 2, 3, 4, 5, 6), NTuple{6, Int})
true</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/tuple.jl#L4-L14">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.NamedTuple" href="#Core.NamedTuple"><code>Core.NamedTuple</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">NamedTuple</code></pre><p><code>NamedTuple</code>s are, as their name suggests, named <a href="#Core.Tuple"><code>Tuple</code></a>s. That is, they're a tuple-like collection of values, where each entry has a unique name, represented as a <a href="#Core.Symbol"><code>Symbol</code></a>. Like <code>Tuple</code>s, <code>NamedTuple</code>s are immutable; neither the names nor the values can be modified in place after construction.</p><p>Accessing the value associated with a name in a named tuple can be done using field access syntax, e.g. <code>x.a</code>, or using <a href="../collections/#Base.getindex"><code>getindex</code></a>, e.g. <code>x[:a]</code> or <code>x[(:a, :b)]</code>. A tuple of the names can be obtained using <a href="../collections/#Base.keys"><code>keys</code></a>, and a tuple of the values can be obtained using <a href="../collections/#Base.values"><code>values</code></a>.</p><div class="admonition is-info"><header class="admonition-header">Note</header><div class="admonition-body"><p>Iteration over <code>NamedTuple</code>s produces the <em>values</em> without the names. (See example below.) To iterate over the name-value pairs, use the <a href="../collections/#Base.pairs"><code>pairs</code></a> function.</p></div></div><p>The <a href="#Base.@NamedTuple"><code>@NamedTuple</code></a> macro can be used for conveniently declaring <code>NamedTuple</code> types.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> x = (a=1, b=2)
(a = 1, b = 2)
julia> x.a
1
julia> x[:a]
1
julia> x[(:a,)]
(a = 1,)
julia> keys(x)
(:a, :b)
julia> values(x)
(1, 2)
julia> collect(x)
2-element Vector{Int64}:
1
2
julia> collect(pairs(x))
2-element Vector{Pair{Symbol, Int64}}:
:a => 1
:b => 2</code></pre><p>In a similar fashion as to how one can define keyword arguments programmatically, a named tuple can be created by giving a pair <code>name::Symbol => value</code> or splatting an iterator yielding such pairs after a semicolon inside a tuple literal:</p><pre><code class="language-julia-repl">julia> (; :a => 1)
(a = 1,)
julia> keys = (:a, :b, :c); values = (1, 2, 3);
julia> (; zip(keys, values)...)
(a = 1, b = 2, c = 3)</code></pre><p>As in keyword arguments, identifiers and dot expressions imply names:</p><pre><code class="language-julia-repl">julia> x = 0
0
julia> t = (; x)
(x = 0,)
julia> (; t.x)
(x = 0,)</code></pre><div class="admonition is-compat"><header class="admonition-header">Julia 1.5</header><div class="admonition-body"><p>Implicit names from identifiers and dot expressions are available as of Julia 1.5.</p></div></div><div class="admonition is-compat"><header class="admonition-header">Julia 1.7</header><div class="admonition-body"><p>Use of <code>getindex</code> methods with multiple <code>Symbol</code>s is available as of Julia 1.7.</p></div></div></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/namedtuple.jl#L3-L85">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.@NamedTuple" href="#Base.@NamedTuple"><code>Base.@NamedTuple</code></a> — <span class="docstring-category">Macro</span></header><section><div><pre><code class="language-julia">@NamedTuple{key1::Type1, key2::Type2, ...}
@NamedTuple begin key1::Type1; key2::Type2; ...; end</code></pre><p>This macro gives a more convenient syntax for declaring <code>NamedTuple</code> types. It returns a <code>NamedTuple</code> type with the given keys and types, equivalent to <code>NamedTuple{(:key1, :key2, ...), Tuple{Type1,Type2,...}}</code>. If the <code>::Type</code> declaration is omitted, it is taken to be <code>Any</code>. The <code>begin ... end</code> form allows the declarations to be split across multiple lines (similar to a <code>struct</code> declaration), but is otherwise equivalent.</p><p>For example, the tuple <code>(a=3.1, b="hello")</code> has a type <code>NamedTuple{(:a, :b),Tuple{Float64,String}}</code>, which can also be declared via <code>@NamedTuple</code> as:</p><pre><code class="language-julia-repl">julia> @NamedTuple{a::Float64, b::String}
NamedTuple{(:a, :b), Tuple{Float64, String}}
julia> @NamedTuple begin
a::Float64
b::String
end
NamedTuple{(:a, :b), Tuple{Float64, String}}</code></pre><div class="admonition is-compat"><header class="admonition-header">Julia 1.5</header><div class="admonition-body"><p>This macro is available as of Julia 1.5.</p></div></div></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/namedtuple.jl#L382-L408">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Val" href="#Base.Val"><code>Base.Val</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Val(c)</code></pre><p>Return <code>Val{c}()</code>, which contains no run-time data. Types like this can be used to pass the information between functions through the value <code>c</code>, which must be an <code>isbits</code> value or a <code>Symbol</code>. The intent of this construct is to be able to dispatch on constants directly (at compile time) without having to test the value of the constant at run time.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> f(::Val{true}) = "Good"
f (generic function with 1 method)
julia> f(::Val{false}) = "Bad"
f (generic function with 2 methods)
julia> f(Val(true))
"Good"</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/essentials.jl#L691-L710">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.Vararg" href="#Core.Vararg"><code>Core.Vararg</code></a> — <span class="docstring-category">Constant</span></header><section><div><pre><code class="language-julia">Vararg{T,N}</code></pre><p>The last parameter of a tuple type <a href="#Core.Tuple"><code>Tuple</code></a> can be the special value <code>Vararg</code>, which denotes any number of trailing elements. <code>Vararg{T,N}</code> corresponds to exactly <code>N</code> elements of type <code>T</code>. Finally <code>Vararg{T}</code> corresponds to zero or more elements of type <code>T</code>. <code>Vararg</code> tuple types are used to represent the arguments accepted by varargs methods (see the section on <a href="base/@ref">Varargs Functions</a> in the manual.)</p><p>See also <a href="#Core.NTuple"><code>NTuple</code></a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> mytupletype = Tuple{AbstractString, Vararg{Int}}
Tuple{AbstractString, Vararg{Int64}}
julia> isa(("1",), mytupletype)
true
julia> isa(("1",1), mytupletype)
true
julia> isa(("1",1,2), mytupletype)
true
julia> isa(("1",1,2,3.0), mytupletype)
false</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L2592-L2619">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.Nothing" href="#Core.Nothing"><code>Core.Nothing</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Nothing</code></pre><p>A type with no fields that is the type of <a href="../constants/#Core.nothing"><code>nothing</code></a>.</p><p>See also: <a href="#Base.isnothing"><code>isnothing</code></a>, <a href="#Base.Some"><code>Some</code></a>, <a href="#Base.Missing"><code>Missing</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L1280-L1286">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.isnothing" href="#Base.isnothing"><code>Base.isnothing</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">isnothing(x)</code></pre><p>Return <code>true</code> if <code>x === nothing</code>, and return <code>false</code> if not.</p><div class="admonition is-compat"><header class="admonition-header">Julia 1.1</header><div class="admonition-body"><p>This function requires at least Julia 1.1.</p></div></div><p>See also <a href="#Base.something"><code>something</code></a>, <a href="#Base.notnothing"><code>notnothing</code></a>, <a href="#Base.ismissing"><code>ismissing</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/some.jl#L60-L69">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.notnothing" href="#Base.notnothing"><code>Base.notnothing</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">notnothing(x)</code></pre><p>Throw an error if <code>x === nothing</code>, and return <code>x</code> if not.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/some.jl#L52-L56">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Some" href="#Base.Some"><code>Base.Some</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Some{T}</code></pre><p>A wrapper type used in <code>Union{Some{T}, Nothing}</code> to distinguish between the absence of a value (<a href="../constants/#Core.nothing"><code>nothing</code></a>) and the presence of a <code>nothing</code> value (i.e. <code>Some(nothing)</code>).</p><p>Use <a href="#Base.something"><code>something</code></a> to access the value wrapped by a <code>Some</code> object.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/some.jl#L3-L10">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.something" href="#Base.something"><code>Base.something</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">something(x...)</code></pre><p>Return the first value in the arguments which is not equal to <a href="../constants/#Core.nothing"><code>nothing</code></a>, if any. Otherwise throw an error. Arguments of type <a href="#Base.Some"><code>Some</code></a> are unwrapped.</p><p>See also <a href="#Base.coalesce"><code>coalesce</code></a>, <a href="#Base.skipmissing"><code>skipmissing</code></a>, <a href="#Base.@something"><code>@something</code></a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> something(nothing, 1)
1
julia> something(Some(1), nothing)
1
julia> something(missing, nothing)
missing
julia> something(nothing, nothing)
ERROR: ArgumentError: No value arguments present</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/some.jl#L73-L96">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.@something" href="#Base.@something"><code>Base.@something</code></a> — <span class="docstring-category">Macro</span></header><section><div><pre><code class="language-julia">@something(x...)</code></pre><p>Short-circuiting version of <a href="#Base.something"><code>something</code></a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> f(x) = (println("f($x)"); nothing);
julia> a = 1;
julia> a = @something a f(2) f(3) error("Unable to find default for `a`")
1
julia> b = nothing;
julia> b = @something b f(2) f(3) error("Unable to find default for `b`")
f(2)
f(3)
ERROR: Unable to find default for `b`
[...]
julia> b = @something b f(2) f(3) Some(nothing)
f(2)
f(3)
julia> b === nothing
true</code></pre><div class="admonition is-compat"><header class="admonition-header">Julia 1.7</header><div class="admonition-body"><p>This macro is available as of Julia 1.7.</p></div></div></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/some.jl#L105-L137">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Enums.Enum" href="#Base.Enums.Enum"><code>Base.Enums.Enum</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Enum{T<:Integer}</code></pre><p>The abstract supertype of all enumerated types defined with <a href="#Base.Enums.@enum"><code>@enum</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/Enums.jl#L10-L14">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Enums.@enum" href="#Base.Enums.@enum"><code>Base.Enums.@enum</code></a> — <span class="docstring-category">Macro</span></header><section><div><pre><code class="language-julia">@enum EnumName[::BaseType] value1[=x] value2[=y]</code></pre><p>Create an <code>Enum{BaseType}</code> subtype with name <code>EnumName</code> and enum member values of <code>value1</code> and <code>value2</code> with optional assigned values of <code>x</code> and <code>y</code>, respectively. <code>EnumName</code> can be used just like other types and enum member values as regular values, such as</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> @enum Fruit apple=1 orange=2 kiwi=3
julia> f(x::Fruit) = "I'm a Fruit with value: $(Int(x))"
f (generic function with 1 method)
julia> f(apple)
"I'm a Fruit with value: 1"
julia> Fruit(1)
apple::Fruit = 1</code></pre><p>Values can also be specified inside a <code>begin</code> block, e.g.</p><pre><code class="language-julia">@enum EnumName begin
value1
value2
end</code></pre><p><code>BaseType</code>, which defaults to <a href="../numbers/#Core.Int32"><code>Int32</code></a>, must be a primitive subtype of <code>Integer</code>. Member values can be converted between the enum type and <code>BaseType</code>. <code>read</code> and <code>write</code> perform these conversions automatically. In case the enum is created with a non-default <code>BaseType</code>, <code>Integer(value1)</code> will return the integer <code>value1</code> with the type <code>BaseType</code>.</p><p>To list all the instances of an enum use <code>instances</code>, e.g.</p><pre><code class="language-julia-repl">julia> instances(Fruit)
(apple, orange, kiwi)</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/Enums.jl#L87-L128">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.Expr" href="#Core.Expr"><code>Core.Expr</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Expr(head::Symbol, args...)</code></pre><p>A type representing compound expressions in parsed julia code (ASTs). Each expression consists of a <code>head</code> <code>Symbol</code> identifying which kind of expression it is (e.g. a call, for loop, conditional statement, etc.), and subexpressions (e.g. the arguments of a call). The subexpressions are stored in a <code>Vector{Any}</code> field called <code>args</code>.</p><p>See the manual chapter on <a href="../../manual/metaprogramming/#Metaprogramming">Metaprogramming</a> and the developer documentation <a href="base/@ref">Julia ASTs</a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> Expr(:call, :+, 1, 2)
:(1 + 2)
julia> dump(:(a ? b : c))
Expr
head: Symbol if
args: Array{Any}((3,))
1: Symbol a
2: Symbol b
3: Symbol c</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L534-L559">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.Symbol" href="#Core.Symbol"><code>Core.Symbol</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Symbol</code></pre><p>The type of object used to represent identifiers in parsed julia code (ASTs). Also often used as a name or label to identify an entity (e.g. as a dictionary key). <code>Symbol</code>s can be entered using the <code>:</code> quote operator:</p><pre><code class="language-julia-repl">julia> :name
:name
julia> typeof(:name)
Symbol
julia> x = 42
42
julia> eval(:x)
42</code></pre><p><code>Symbol</code>s can also be constructed from strings or other values by calling the constructor <code>Symbol(x...)</code>.</p><p><code>Symbol</code>s are immutable and should be compared using <code>===</code>. The implementation re-uses the same object for all <code>Symbol</code>s with the same name, so comparison tends to be efficient (it can just compare pointers).</p><p>Unlike strings, <code>Symbol</code>s are "atomic" or "scalar" entities that do not support iteration over characters.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L1875-L1903">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.Symbol-Tuple" href="#Core.Symbol-Tuple"><code>Core.Symbol</code></a> — <span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia">Symbol(x...) -> Symbol</code></pre><p>Create a <a href="#Core.Symbol"><code>Symbol</code></a> by concatenating the string representations of the arguments together.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> Symbol("my", "name")
:myname
julia> Symbol("day", 4)
:day4</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L1906-L1919">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.Module" href="#Core.Module"><code>Core.Module</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Module</code></pre><p>A <code>Module</code> is a separate global variable workspace. See <a href="#module"><code>module</code></a> and the <a href="../../manual/modules/#modules">manual section about modules</a> for details.</p><pre><code class="language-none">Module(name::Symbol=:anonymous, std_imports=true, default_names=true)</code></pre><p>Return a module with the specified name. A <code>baremodule</code> corresponds to <code>Module(:ModuleName, false)</code></p><p>An empty module containing no names at all can be created with <code>Module(:ModuleName, false, false)</code>. This module will not import <code>Base</code> or <code>Core</code> and does not contain a reference to itself.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L2812-L2823">source</a></section></article><h2 id="Generic-Functions"><a class="docs-heading-anchor" href="#Generic-Functions">Generic Functions</a><a id="Generic-Functions-1"></a><a class="docs-heading-anchor-permalink" href="#Generic-Functions" title="Permalink"></a></h2><article class="docstring"><header><a class="docstring-binding" id="Core.Function" href="#Core.Function"><code>Core.Function</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Function</code></pre><p>Abstract type of all functions.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> isa(+, Function)
true
julia> typeof(sin)
typeof(sin) (singleton type of function sin, subtype of Function)
julia> ans <: Function
true</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L1356-L1372">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.hasmethod" href="#Base.hasmethod"><code>Base.hasmethod</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">hasmethod(f, t::Type{<:Tuple}[, kwnames]; world=get_world_counter()) -> Bool</code></pre><p>Determine whether the given generic function has a method matching the given <code>Tuple</code> of argument types with the upper bound of world age given by <code>world</code>.</p><p>If a tuple of keyword argument names <code>kwnames</code> is provided, this also checks whether the method of <code>f</code> matching <code>t</code> has the given keyword argument names. If the matching method accepts a variable number of keyword arguments, e.g. with <code>kwargs...</code>, any names given in <code>kwnames</code> are considered valid. Otherwise the provided names must be a subset of the method's keyword arguments.</p><p>See also <a href="#Core.applicable"><code>applicable</code></a>.</p><div class="admonition is-compat"><header class="admonition-header">Julia 1.2</header><div class="admonition-body"><p>Providing keyword argument names requires Julia 1.2 or later.</p></div></div><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> hasmethod(length, Tuple{Array})
true
julia> f(; oranges=0) = oranges;
julia> hasmethod(f, Tuple{}, (:oranges,))
true
julia> hasmethod(f, Tuple{}, (:apples, :bananas))
false
julia> g(; xs...) = 4;
julia> hasmethod(g, Tuple{}, (:a, :b, :c, :d)) # g accepts arbitrary kwargs
true</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L1480-L1515">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.applicable" href="#Core.applicable"><code>Core.applicable</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">applicable(f, args...) -> Bool</code></pre><p>Determine whether the given generic function has a method applicable to the given arguments.</p><p>See also <a href="#Base.hasmethod"><code>hasmethod</code></a>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> function f(x, y)
x + y
end;
julia> applicable(f, 1)
false
julia> applicable(f, 1, 2)
true</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L1661-L1680">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.isambiguous" href="#Base.isambiguous"><code>Base.isambiguous</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">Base.isambiguous(m1, m2; ambiguous_bottom=false) -> Bool</code></pre><p>Determine whether two methods <code>m1</code> and <code>m2</code> may be ambiguous for some call signature. This test is performed in the context of other methods of the same function; in isolation, <code>m1</code> and <code>m2</code> might be ambiguous, but if a third method resolving the ambiguity has been defined, this returns <code>false</code>. Alternatively, in isolation <code>m1</code> and <code>m2</code> might be ordered, but if a third method cannot be sorted with them, they may cause an ambiguity together.</p><p>For parametric types, the <code>ambiguous_bottom</code> keyword argument controls whether <code>Union{}</code> counts as an ambiguous intersection of type parameters – when <code>true</code>, it is considered ambiguous, when <code>false</code> it is not.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> foo(x::Complex{<:Integer}) = 1
foo (generic function with 1 method)
julia> foo(x::Complex{<:Rational}) = 2
foo (generic function with 2 methods)
julia> m1, m2 = collect(methods(foo));
julia> typeintersect(m1.sig, m2.sig)
Tuple{typeof(foo), Complex{Union{}}}
julia> Base.isambiguous(m1, m2, ambiguous_bottom=true)
true
julia> Base.isambiguous(m1, m2, ambiguous_bottom=false)
false</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L1579-L1612">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Core.invoke" href="#Core.invoke"><code>Core.invoke</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">invoke(f, argtypes::Type, args...; kwargs...)</code></pre><p>Invoke a method for the given generic function <code>f</code> matching the specified types <code>argtypes</code> on the specified arguments <code>args</code> and passing the keyword arguments <code>kwargs</code>. The arguments <code>args</code> must conform with the specified types in <code>argtypes</code>, i.e. conversion is not automatically performed. This method allows invoking a method other than the most specific matching method, which is useful when the behavior of a more general definition is explicitly needed (often as part of the implementation of a more specific method of the same function).</p><p>Be careful when using <code>invoke</code> for functions that you don't write. What definition is used for given <code>argtypes</code> is an implementation detail unless the function is explicitly states that calling with certain <code>argtypes</code> is a part of public API. For example, the change between <code>f1</code> and <code>f2</code> in the example below is usually considered compatible because the change is invisible by the caller with a normal (non-<code>invoke</code>) call. However, the change is visible if you use <code>invoke</code>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> f(x::Real) = x^2;
julia> f(x::Integer) = 1 + invoke(f, Tuple{Real}, x);
julia> f(2)
5
julia> f1(::Integer) = Integer
f1(::Real) = Real;
julia> f2(x::Real) = _f2(x)
_f2(::Integer) = Integer
_f2(_) = Real;
julia> f1(1)
Integer
julia> f2(1)
Integer
julia> invoke(f1, Tuple{Real}, 1)
Real
julia> invoke(f2, Tuple{Real}, 1)
Integer</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L1683-L1728">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.@invoke" href="#Base.@invoke"><code>Base.@invoke</code></a> — <span class="docstring-category">Macro</span></header><section><div><pre><code class="language-julia">@invoke f(arg::T, ...; kwargs...)</code></pre><p>Provides a convenient way to call <a href="#Core.invoke"><code>invoke</code></a>; <code>@invoke f(arg1::T1, arg2::T2; kwargs...)</code> will be expanded into <code>invoke(f, Tuple{T1,T2}, arg1, arg2; kwargs...)</code>. When an argument's type annotation is omitted, it's specified as <code>Any</code> argument, e.g. <code>@invoke f(arg1::T, arg2)</code> will be expanded into <code>invoke(f, Tuple{T,Any}, arg1, arg2)</code>.</p><div class="admonition is-compat"><header class="admonition-header">Julia 1.7</header><div class="admonition-body"><p>This macro requires Julia 1.7 or later.</p></div></div></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L1767-L1777">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.invokelatest" href="#Base.invokelatest"><code>Base.invokelatest</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">invokelatest(f, args...; kwargs...)</code></pre><p>Calls <code>f(args...; kwargs...)</code>, but guarantees that the most recent method of <code>f</code> will be executed. This is useful in specialized circumstances, e.g. long-running event loops or callback functions that may call obsolete versions of a function <code>f</code>. (The drawback is that <code>invokelatest</code> is somewhat slower than calling <code>f</code> directly, and the type of the result cannot be inferred by the compiler.)</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/essentials.jl#L716-L725">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.@invokelatest" href="#Base.@invokelatest"><code>Base.@invokelatest</code></a> — <span class="docstring-category">Macro</span></header><section><div><pre><code class="language-julia">@invokelatest f(args...; kwargs...)</code></pre><p>Provides a convenient way to call <a href="#Base.invokelatest"><code>Base.invokelatest</code></a>. <code>@invokelatest f(args...; kwargs...)</code> will simply be expanded into <code>Base.invokelatest(f, args...; kwargs...)</code>.</p><div class="admonition is-compat"><header class="admonition-header">Julia 1.7</header><div class="admonition-body"><p>This macro requires Julia 1.7 or later.</p></div></div></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/reflection.jl#L1787-L1796">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="new" href="#new"><code>new</code></a> — <span class="docstring-category">Keyword</span></header><section><div><pre><code class="language-julia">new, or new{A,B,...}</code></pre><p>Special function available to inner constructors which creates a new object of the type. The form new{A,B,...} explicitly specifies values of parameters for parametric types. See the manual section on <a href="../../manual/constructors/#man-inner-constructor-methods">Inner Constructor Methods</a> for more information.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/docs/basedocs.jl#L1190-L1197">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.:|>" href="#Base.:|>"><code>Base.:|></code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">|>(x, f)</code></pre><p>Applies a function to the preceding argument. This allows for easy function chaining.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> [1:5;] |> (x->x.^2) |> sum |> inv
0.01818181818181818</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/operators.jl#L900-L910">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.:∘" href="#Base.:∘"><code>Base.:∘</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">f ∘ g</code></pre><p>Compose functions: i.e. <code>(f ∘ g)(args...; kwargs...)</code> means <code>f(g(args...; kwargs...))</code>. The <code>∘</code> symbol can be entered in the Julia REPL (and most editors, appropriately configured) by typing <code>\circ<tab></code>.</p><p>Function composition also works in prefix form: <code>∘(f, g)</code> is the same as <code>f ∘ g</code>. The prefix form supports composition of multiple functions: <code>∘(f, g, h) = f ∘ g ∘ h</code> and splatting <code>∘(fs...)</code> for composing an iterable collection of functions.</p><div class="admonition is-compat"><header class="admonition-header">Julia 1.4</header><div class="admonition-body"><p>Multiple function composition requires at least Julia 1.4.</p></div></div><div class="admonition is-compat"><header class="admonition-header">Julia 1.5</header><div class="admonition-body"><p>Composition of one function ∘(f) requires at least Julia 1.5.</p></div></div><div class="admonition is-compat"><header class="admonition-header">Julia 1.7</header><div class="admonition-body"><p>Using keyword arguments requires at least Julia 1.7.</p></div></div><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> map(uppercase∘first, ["apple", "banana", "carrot"])
3-element Vector{Char}:
'A': ASCII/Unicode U+0041 (category Lu: Letter, uppercase)
'B': ASCII/Unicode U+0042 (category Lu: Letter, uppercase)
'C': ASCII/Unicode U+0043 (category Lu: Letter, uppercase)
julia> fs = [
x -> 2x
x -> x/2
x -> x-1
x -> x+1
];
julia> ∘(fs...)(3)
3.0</code></pre><p>See also <a href="#Base.ComposedFunction"><code>ComposedFunction</code></a>, <a href="../math/#Base.:!"><code>!f::Function</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/operators.jl#L954-L992">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.ComposedFunction" href="#Base.ComposedFunction"><code>Base.ComposedFunction</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">ComposedFunction{Outer,Inner} <: Function</code></pre><p>Represents the composition of two callable objects <code>outer::Outer</code> and <code>inner::Inner</code>. That is</p><pre><code class="language-julia">ComposedFunction(outer, inner)(args...; kw...) === outer(inner(args...; kw...))</code></pre><p>The preferred way to construct instance of <code>ComposedFunction</code> is to use the composition operator <a href="#Base.:∘"><code>∘</code></a>:</p><pre><code class="language-julia-repl">julia> sin ∘ cos === ComposedFunction(sin, cos)
true
julia> typeof(sin∘cos)
ComposedFunction{typeof(sin), typeof(cos)}</code></pre><p>The composed pieces are stored in the fields of <code>ComposedFunction</code> and can be retrieved as follows:</p><pre><code class="language-julia-repl">julia> composition = sin ∘ cos
sin ∘ cos
julia> composition.outer === sin
true
julia> composition.inner === cos
true</code></pre><div class="admonition is-compat"><header class="admonition-header">Julia 1.6</header><div class="admonition-body"><p>ComposedFunction requires at least Julia 1.6. In earlier versions <code>∘</code> returns an anonymous function instead.</p></div></div><p>See also <a href="#Base.:∘"><code>∘</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/operators.jl#L995-L1025">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.splat" href="#Base.splat"><code>Base.splat</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">splat(f)</code></pre><p>Defined as</p><pre><code class="language-julia"> splat(f) = args->f(args...)</code></pre><p>i.e. given a function returns a new function that takes one argument and splats its argument into the original function. This is useful as an adaptor to pass a multi-argument function in a context that expects a single argument, but passes a tuple as that single argument.</p><p><strong>Example usage:</strong></p><pre><code class="language-julia-repl">julia> map(Base.splat(+), zip(1:3,4:6))
3-element Vector{Int64}:
5
7
9</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/operators.jl#L1202-L1222">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Fix1" href="#Base.Fix1"><code>Base.Fix1</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Fix1(f, x)</code></pre><p>A type representing a partially-applied version of the two-argument function <code>f</code>, with the first argument fixed to the value "x". In other words, <code>Fix1(f, x)</code> behaves similarly to <code>y->f(x, y)</code>.</p><p>See also <a href="#Base.Fix2"><code>Fix2</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/operators.jl#L1079-L1087">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.Fix2" href="#Base.Fix2"><code>Base.Fix2</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia">Fix2(f, x)</code></pre><p>A type representing a partially-applied version of the two-argument function <code>f</code>, with the second argument fixed to the value "x". In other words, <code>Fix2(f, x)</code> behaves similarly to <code>y->f(y, x)</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/operators.jl#L1098-L1104">source</a></section></article><h2 id="Syntax"><a class="docs-heading-anchor" href="#Syntax">Syntax</a><a id="Syntax-1"></a><a class="docs-heading-anchor-permalink" href="#Syntax" title="Permalink"></a></h2><article class="docstring"><header><a class="docstring-binding" id="Core.eval" href="#Core.eval"><code>Core.eval</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">Core.eval(m::Module, expr)</code></pre><p>Evaluate an expression in the given module and return the result.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/expr.jl#L176-L180">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.MainInclude.eval" href="#Base.MainInclude.eval"><code>Base.MainInclude.eval</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">eval(expr)</code></pre><p>Evaluate an expression in the global scope of the containing module. Every <code>Module</code> (except those defined with <code>baremodule</code>) has its own 1-argument definition of <code>eval</code>, which evaluates expressions in that module.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/client.jl#L481-L487">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.@eval" href="#Base.@eval"><code>Base.@eval</code></a> — <span class="docstring-category">Macro</span></header><section><div><pre><code class="language-julia">@eval [mod,] ex</code></pre><p>Evaluate an expression with values interpolated into it using <code>eval</code>. If two arguments are provided, the first is the module to evaluate in.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/essentials.jl#L220-L225">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.evalfile" href="#Base.evalfile"><code>Base.evalfile</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">evalfile(path::AbstractString, args::Vector{String}=String[])</code></pre><p>Load the file using <a href="#Base.include"><code>include</code></a>, evaluate all expressions, and return the value of the last one.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/loading.jl#L1498-L1503">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.esc" href="#Base.esc"><code>Base.esc</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">esc(e)</code></pre><p>Only valid in the context of an <a href="#Core.Expr"><code>Expr</code></a> returned from a macro. Prevents the macro hygiene pass from turning embedded variables into gensym variables. See the <a href="../../manual/metaprogramming/#man-macros">Macros</a> section of the Metaprogramming chapter of the manual for more details and examples.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/essentials.jl#L494-L500">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.@inbounds" href="#Base.@inbounds"><code>Base.@inbounds</code></a> — <span class="docstring-category">Macro</span></header><section><div><pre><code class="language-julia">@inbounds(blk)</code></pre><p>Eliminates array bounds checking within expressions.</p><p>In the example below the in-range check for referencing element <code>i</code> of array <code>A</code> is skipped to improve performance.</p><pre><code class="language-julia">function sum(A::AbstractArray)
r = zero(eltype(A))
for i in eachindex(A)
@inbounds r += A[i]
end
return r
end</code></pre><div class="admonition is-warning"><header class="admonition-header">Warning</header><div class="admonition-body"><p>Using <code>@inbounds</code> may return incorrect results/crashes/corruption for out-of-bounds indices. The user is responsible for checking it manually. Only use <code>@inbounds</code> when it is certain from the information locally available that all accesses are in bounds.</p></div></div></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/essentials.jl#L551-L575">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.@boundscheck" href="#Base.@boundscheck"><code>Base.@boundscheck</code></a> — <span class="docstring-category">Macro</span></header><section><div><pre><code class="language-julia">@boundscheck(blk)</code></pre><p>Annotates the expression <code>blk</code> as a bounds checking block, allowing it to be elided by <a href="#Base.@inbounds"><code>@inbounds</code></a>.</p><div class="admonition is-info"><header class="admonition-header">Note</header><div class="admonition-body"><p>The function in which <code>@boundscheck</code> is written must be inlined into its caller in order for <code>@inbounds</code> to have effect.</p></div></div><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> @inline function g(A, i)
@boundscheck checkbounds(A, i)
return "accessing ($A)[$i]"
end;
julia> f1() = return g(1:2, -1);
julia> f2() = @inbounds return g(1:2, -1);
julia> f1()
ERROR: BoundsError: attempt to access 2-element UnitRange{Int64} at index [-1]
Stacktrace:
[1] throw_boundserror(::UnitRange{Int64}, ::Tuple{Int64}) at ./abstractarray.jl:455
[2] checkbounds at ./abstractarray.jl:420 [inlined]
[3] g at ./none:2 [inlined]
[4] f1() at ./none:1
[5] top-level scope
julia> f2()
"accessing (1:2)[-1]"</code></pre><div class="admonition is-warning"><header class="admonition-header">Warning</header><div class="admonition-body"><p>The <code>@boundscheck</code> annotation allows you, as a library writer, to opt-in to allowing <em>other code</em> to remove your bounds checks with <a href="#Base.@inbounds"><code>@inbounds</code></a>. As noted there, the caller must verify—using information they can access—that their accesses are valid before using <code>@inbounds</code>. For indexing into your <a href="../arrays/#Core.AbstractArray"><code>AbstractArray</code></a> subclasses, for example, this involves checking the indices against its <a href="../arrays/#Base.axes-Tuple{Any}"><code>axes</code></a>. Therefore, <code>@boundscheck</code> annotations should only be added to a <a href="../collections/#Base.getindex"><code>getindex</code></a> or <a href="../collections/#Base.setindex!"><code>setindex!</code></a> implementation after you are certain its behavior is correct.</p></div></div></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/essentials.jl#L503-L546">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.@propagate_inbounds" href="#Base.@propagate_inbounds"><code>Base.@propagate_inbounds</code></a> — <span class="docstring-category">Macro</span></header><section><div><pre><code class="language-julia">@propagate_inbounds</code></pre><p>Tells the compiler to inline a function while retaining the caller's inbounds context.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/expr.jl#L637-L641">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.@inline" href="#Base.@inline"><code>Base.@inline</code></a> — <span class="docstring-category">Macro</span></header><section><div><pre><code class="language-julia">@inline</code></pre><p>Give a hint to the compiler that this function is worth inlining.</p><p>Small functions typically do not need the <code>@inline</code> annotation, as the compiler does it automatically. By using <code>@inline</code> on bigger functions, an extra nudge can be given to the compiler to inline it.</p><p><code>@inline</code> can be applied immediately before the definition or in its function body.</p><pre><code class="language-julia"># annotate long-form definition
@inline function longdef(x)
...
end
# annotate short-form definition
@inline shortdef(x) = ...
# annotate anonymous function that a `do` block creates
f() do
@inline
...
end</code></pre><div class="admonition is-compat"><header class="admonition-header">Julia 1.8</header><div class="admonition-body"><p>The usage within a function body requires at least Julia 1.8.</p></div></div><hr/><pre><code class="language-none">@inline block</code></pre><p>Give a hint to the compiler that calls within <code>block</code> are worth inlining.</p><pre><code class="language-julia"># The compiler will try to inline `f`
@inline f(...)
# The compiler will try to inline `f`, `g` and `+`
@inline f(...) + g(...)</code></pre><div class="admonition is-info"><header class="admonition-header">Note</header><div class="admonition-body"><p>A callsite annotation always has the precedence over the annotation applied to the definition of the called function:</p><pre><code class="language-julia">@noinline function explicit_noinline(args...)
# body
end
let
@inline explicit_noinline(args...) # will be inlined
end</code></pre></div></div><div class="admonition is-info"><header class="admonition-header">Note</header><div class="admonition-body"><p>When there are nested callsite annotations, the innermost annotation has the precedence:</p><pre><code class="language-julia">@noinline let a0, b0 = ...
a = @inline f(a0) # the compiler will try to inline this call
b = f(b0) # the compiler will NOT try to inline this call
return a, b
end</code></pre></div></div><div class="admonition is-warning"><header class="admonition-header">Warning</header><div class="admonition-body"><p>Although a callsite annotation will try to force inlining in regardless of the cost model, there are still chances it can't succeed in it. Especially, recursive calls can not be inlined even if they are annotated as <code>@inline</code>d.</p></div></div><div class="admonition is-compat"><header class="admonition-header">Julia 1.8</header><div class="admonition-body"><p>The callsite annotation requires at least Julia 1.8.</p></div></div></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaLang/julia/blob/17cfb8e65ead377bf1b4598d8a9869144142c84e/base/expr.jl#L183-L256">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Base.@noinline" href="#Base.@noinline"><code>Base.@noinline</code></a> — <span class="docstring-category">Macro</span></header><section><div><pre><code class="language-julia">@noinline</code></pre><p>Give a hint to the compiler that it should not inline a function.</p><p>Small functions are typically inlined automatically. By using <code>@noinline</code> on small functions, auto-inlining can be prevented.</p><p><code>@noinline</code> can be applied immediately before the definition or in its function body.</p><pre><code class="language-julia"># annotate long-form definition
@noinline function longdef(x)
...
end
# annotate short-form definition
@noinline shortdef(x) = ...
# annotate anonymous function that a `do` block creates
f() do
@noinline
...
end</code></pre><div class="admonition is-compat"><header class="admonition-header">Julia 1.8</header><div class="admonition-body"><p>The usage within a function body requires at least Julia 1.8.</p></div></div><hr/><pre><code class="language-none">@noinline block</code></pre><p>Give a hint to the compiler that it should not inline the calls within <code>block</code>.</p><pre><code class="language-julia"># The compiler will try to not inline `f`
@noinline f(...)
# The compiler will try to not inline `f`, `g` and `+`
@noinline f(...) + g(...)</code></pre><div class="admonition is-info"><header class="admonition-header">Note</header><div class="admonition-body"><p>A callsite annotation always has the precedence over the annotation applied to the definition of the called function:</p><pre><code class="language-julia">@inline function explicit_inline(args...)
# body