Skip to content

docs: add isnullish function faq documents #480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading