Skip to content

Commit

Permalink
Merge pull request #480 from kcl-lang/faq-isnullish-func
Browse files Browse the repository at this point in the history
docs: add isnullish function faq documents
  • Loading branch information
Peefy authored Nov 6, 2024
2 parents 44e7f0d + 6eca023 commit 8ce7ee6
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/user_docs/support/faq-kcl.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,16 @@ isEmptyList = bool(_emptyList)
isEmptyDict = bool(_emptyDict)
```

In addition, if we want to determine that a variable is only `None`/`Undefined` and not empty, we can use the following expression or the built-in function `isnullish()`

```python
a = None
_emptyList = []
isEmptyList = bool(_emptyList)
isNullishList1 = _emptyList not in [None, Undefined]
isNullishList2 = isnullish(_emptyList)
```

## 12. How to concatenate strings, format strings, check string prefixes and suffixes and replace string content?

- The `+` operator can be used to concatenate two strings in KCL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,16 @@ isEmptyList = bool(_emptyList)
isEmptyDict = bool(_emptyDict)
```

此外,如果我们想要判断一个变量仅为 `None`/`Undefined`,而不为空,则可以使用下面的表达式或者 `isnullish()` 内置函数

```python
a = None
_emptyList = []
isEmptyList = bool(_emptyList)
isNullishList1 = _emptyList not in [None, Undefined]
isNullishList2 = isnullish(_emptyList)
```

## 12. 字符串怎样拼接、怎样格式化字符串、怎样检查字符串前缀、后缀?怎样替换字符串内容?

- KCL 中可以使用 `+` 运算符连接两个字符串
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,16 @@ isEmptyList = bool(_emptyList)
isEmptyDict = bool(_emptyDict)
```

此外,如果我们想要判断一个变量仅为 `None`/`Undefined`,而不为空,则可以使用下面的表达式或者 `isnullish()` 内置函数

```python
a = None
_emptyList = []
isEmptyList = bool(_emptyList)
isNullishList1 = _emptyList not in [None, Undefined]
isNullishList2 = isnullish(_emptyList)
```

## 12. 字符串怎样拼接、怎样格式化字符串、怎样检查字符串前缀、后缀?怎样替换字符串内容?

- KCL 中可以使用 `+` 运算符连接两个字符串
Expand Down
10 changes: 10 additions & 0 deletions versioned_docs/version-0.10/user_docs/support/faq-kcl.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,16 @@ isEmptyList = bool(_emptyList)
isEmptyDict = bool(_emptyDict)
```

In addition, if we want to determine that a variable is only `None`/`Undefined` and not empty, we can use the following expression or the built-in function `isnullish()`

```python
a = None
_emptyList = []
isEmptyList = bool(_emptyList)
isNullishList1 = _emptyList not in [None, Undefined]
isNullishList2 = isnullish(_emptyList)
```

## 12. How to concatenate strings, format strings, check string prefixes and suffixes and replace string content?

- The `+` operator can be used to concatenate two strings in KCL
Expand Down

0 comments on commit 8ce7ee6

Please sign in to comment.