浏览代码

Improve documentation for `String.get_extension()`

(cherry picked from commit 09eb98c5306f8d9a17287aa5a7509e17d56f2ee0)
Hugo Locurcio 4 年之前
父节点
当前提交
415b7a7bfc
共有 1 个文件被更改,包括 11 次插入1 次删除
  1. 11 1
      doc/classes/String.xml

+ 11 - 1
doc/classes/String.xml

@@ -316,7 +316,17 @@
 		<method name="get_extension">
 			<return type="String" />
 			<description>
-				If the string is a valid file path, returns the extension.
+				Returns the extension without the leading period character ([code].[/code]) if the string is a valid file name or path. If the string does not contain an extension, returns an empty string instead.
+				[codeblock]
+				print("/path/to/file.txt".get_extension())  # "txt"
+				print("file.txt".get_extension())  # "txt"
+				print("file.sample.txt".get_extension())  # "txt"
+				print(".txt".get_extension())  # "txt"
+				print("file.txt.".get_extension())  # "" (empty string)
+				print("file.txt..".get_extension())  # "" (empty string)
+				print("txt".get_extension())  # "" (empty string)
+				print("".get_extension())  # "" (empty string)
+				[/codeblock]
 			</description>
 		</method>
 		<method name="get_file">