Returns the first element of the sequence. >>> seq([1, 2, 3]).first() 1 Raises IndexError when the sequence is empty. >>> seq([]).first() Traceback (most recent call last): ... IndexError: list index out of range :return:
(self)
| 239 | return _wrap(self.take(1)[0]) |
| 240 | |
| 241 | def first(self): |
| 242 | """ |
| 243 | Returns the first element of the sequence. |
| 244 | |
| 245 | >>> seq([1, 2, 3]).first() |
| 246 | 1 |
| 247 | |
| 248 | Raises IndexError when the sequence is empty. |
| 249 | |
| 250 | >>> seq([]).first() |
| 251 | Traceback (most recent call last): |
| 252 | ... |
| 253 | IndexError: list index out of range |
| 254 | |
| 255 | :return: first element of sequence |
| 256 | """ |
| 257 | return self.head() |
| 258 | |
| 259 | def head_option(self): |
| 260 | """ |