The current repo belongs to Closed status, and some functions are restricted. For details, please refer to the description of repo status
1 Star 0 Fork 0

Vijay / option
Closed

Create your Gitee Account
Explore and code with more than 8 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

项目简介

山寨了一个Scala语言的Option数据类型,用来表示可选值的数据结构


composer安装

composer require dreamcat/option

示例

<?php

# 创建有值的对象
$some = new \DreamCat\OptionStruct\Some("value");
# 创建没有值的对象
$none = \DreamCat\OptionStruct\None::sInstance();

# 在使用时一般只传入Option类型
/** @var \DreamCat\OptionStruct\Option $opt */
# 判断是否有没有值
$opt->isDefined();
$opt->isEmpty();
# 获取值 要注意的是如果是None执行get会抛出异常
$value = $opt->get();
# 获取值,不存在返回默认值
$value = $opt->getOrElse($def);

Repository Comments ( 0 )

Sign in to post a comment

About

山寨了一个Scala语言的Option数据类型,用来表示可选值的数据结构 expand collapse
PHP
Cancel

Releases

No release

Contributors

All

Activities

Load More
can not load any more
PHP
1
https://gitee.com/vijay_0215/option.git
git@gitee.com:vijay_0215/option.git
vijay_0215
option
option
master

Search