{"action":"created","issue":{"url":"https://api.github.com/repos/javaslang/javaslang/issues/1180","repository_url":"https://api.github.com/repos/javaslang/javaslang","labels_url":"https://api.github.com/repos/javaslang/javaslang/issues/1180/labels{/name}","comments_url":"https://api.github.com/repos/javaslang/javaslang/issues/1180/comments","events_url":"https://api.github.com/repos/javaslang/javaslang/issues/1180/events","html_url":"https://github.com/javaslang/javaslang/pull/1180","id":138973924,"number":1180,"title":"Try.isEmpty() returns false even when it's a Success with null value","user":{"login":"ggalmazor","id":205913,"avatar_url":"https://avatars.githubusercontent.com/u/205913?v=3","gravatar_id":"","url":"https://api.github.com/users/ggalmazor","html_url":"https://github.com/ggalmazor","followers_url":"https://api.github.com/users/ggalmazor/followers","following_url":"https://api.github.com/users/ggalmazor/following{/other_user}","gists_url":"https://api.github.com/users/ggalmazor/gists{/gist_id}","starred_url":"https://api.github.com/users/ggalmazor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ggalmazor/subscriptions","organizations_url":"https://api.github.com/users/ggalmazor/orgs","repos_url":"https://api.github.com/users/ggalmazor/repos","events_url":"https://api.github.com/users/ggalmazor/events{/privacy}","received_events_url":"https://api.github.com/users/ggalmazor/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-03-07T13:04:29Z","updated_at":"2016-03-08T08:46:33Z","closed_at":"2016-03-08T08:02:07Z","pull_request":{"url":"https://api.github.com/repos/javaslang/javaslang/pulls/1180","html_url":"https://github.com/javaslang/javaslang/pull/1180","diff_url":"https://github.com/javaslang/javaslang/pull/1180.diff","patch_url":"https://github.com/javaslang/javaslang/pull/1180.patch"},"body":"It should return true to comply with: \r\n```Option.of(null).isDefined == Try.of(()->null).toOption().isDefined()```\r\n\r\nThis is also broken on 1.x branch. I can prepare a patch for that as well\r\n\r\nAlso, should ```Try.isEmpty()``` check for types that have an ```isEmpty()``` (like String, List, etc.) implementation and delegate the results? Problem is that there is no common hierarchic ancestor that guarantees the presence of such method. We could just make the \"best effort\" with known types.\r\n"},"comment":{"url":"https://api.github.com/repos/javaslang/javaslang/issues/comments/193665568","html_url":"https://github.com/javaslang/javaslang/pull/1180#issuecomment-193665568","issue_url":"https://api.github.com/repos/javaslang/javaslang/issues/1180","id":193665568,"user":{"login":"danieldietrich","id":743833,"avatar_url":"https://avatars.githubusercontent.com/u/743833?v=3","gravatar_id":"","url":"https://api.github.com/users/danieldietrich","html_url":"https://github.com/danieldietrich","followers_url":"https://api.github.com/users/danieldietrich/followers","following_url":"https://api.github.com/users/danieldietrich/following{/other_user}","gists_url":"https://api.github.com/users/danieldietrich/gists{/gist_id}","starred_url":"https://api.github.com/users/danieldietrich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danieldietrich/subscriptions","organizations_url":"https://api.github.com/users/danieldietrich/orgs","repos_url":"https://api.github.com/users/danieldietrich/repos","events_url":"https://api.github.com/users/danieldietrich/events{/privacy}","received_events_url":"https://api.github.com/users/danieldietrich/received_events","type":"User","site_admin":false},"created_at":"2016-03-08T08:46:33Z","updated_at":"2016-03-08T08:46:33Z","body":"We should not do that. I had a use case where I needed `Some<Void>`. `null` is the only instance here of `Void`. As long as null is part of Java, we can't completely get rid of it without breaking the logical structure or making look things artificial.\r\n\r\nYou could solve your use-case by using `transform` instead of `toOption`:\r\n\r\n```java\r\nTry(...).transform(self -> self.isSuccess() ? Option.of(self.get()) : Option.empty());\r\n```\r\n\r\nor write a helper for that\r\n\r\n```java\r\nTry(...).transform(FancyName::toOption);\r\n\r\nclass FancyName {\r\n    static Function<? super Try<T>, ? extends Option<T>> toOption() {\r\n        return it -> it.isSuccess() ? Option.of(it.get()) : Option.empty());\r\n    }\r\n}\r\n```\r\n"}}