MCPcopy Create free account
hub / github.com/EntilZha/PyFunctional / head_option

Method head_option

functional/pipeline.py:259–273  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 """

Callers 1

test_head_optionMethod · 0.80

Calls 1

headMethod · 0.95

Tested by 1

test_head_optionMethod · 0.64