Returns the first element of the sequence or None, if the sequence is empty. >>> seq([1, 2, 3]).head_option() 1 >>> seq([]).head_option() None :return: first element of sequence or None if sequence is empty
(self)
| 257 | return self.head() |
| 258 | |
| 259 | def head_option(self): |
| 260 | """ |
| 261 | Returns the first element of the sequence or None, if the sequence is empty. |
| 262 | |
| 263 | >>> seq([1, 2, 3]).head_option() |
| 264 | 1 |
| 265 | |
| 266 | >>> seq([]).head_option() |
| 267 | None |
| 268 | |
| 269 | :return: first element of sequence or None if sequence is empty |
| 270 | """ |
| 271 | if not self.sequence: |
| 272 | return None |
| 273 | return self.head() |
| 274 | |
| 275 | def last(self): |
| 276 | """ |