Skip to content

Commit

Permalink
return null instead of 'null' in getString()
Browse files Browse the repository at this point in the history
  • Loading branch information
haifengl committed Nov 22, 2019
1 parent c516809 commit 2e1c56e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions data/src/main/java/smile/data/Tuple.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ default double getDouble(String field) {
* @throws ClassCastException when data type does not match.
*/
default String getString(int i) {
return schema().field(i).toString(get(i));
Object obj = get(i);
return obj == null ? null : schema().field(i).toString(obj);
}

/**
Expand All @@ -277,8 +278,7 @@ default String getString(int i) {
* @throws ClassCastException when data type does not match.
*/
default String getString(String field) {
int i = fieldIndex(field);
return schema().field(i).toString(get(i));
return getString(fieldIndex(field));
}

/**
Expand Down

0 comments on commit 2e1c56e

Please sign in to comment.