前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >DEFAULT keyword in ABAP and Optional Class in Java

DEFAULT keyword in ABAP and Optional Class in Java

作者头像
Jerry Wang
发布2020-01-21 14:59:07
3420
发布2020-01-21 14:59:07
举报

It is ok to use this new ABAP syntax about table expression here since object_ext is passed from UI framework and it is rarely possible that there would be partner or customer to manually pass any other value to parameter it_data.

According to ABAP help, if no row by specified key could be found, exception will be raised, instead of sy-subrc set to a non-zero value for READ TABLE XXX.

so ABAP provides another key word DEFAULT which allows you to provide a default value if specified row does not exist to avoid exception. In example below, line 17 will raise exception while line 19 not.

In Java 8 there is similar mechanism: new class Optional is introduced to avoid application developers’ endless of If XXX != null code to check null:

Unlike many other annotation, this Utility class is not implemented in JVM layer, but just in language layer, as a result it is very easy to develop an Optional class in ABAP as well.

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-01-01 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档